Skip to content

Instantly share code, notes, and snippets.

@redryan
Last active November 19, 2015 17:19
Show Gist options
  • Save redryan/132e73dec29a8c666c91 to your computer and use it in GitHub Desktop.
Save redryan/132e73dec29a8c666c91 to your computer and use it in GitHub Desktop.
Salesforce Chatter embedded in an IFrame
<apex:page controller="ChatterPage" showHeader="false" sidebar="false" standardStylesheets="true">
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
// Capture all clicks on <a> elements and change the URL for the whole window
// Some <a> elements are used for JavaScript function calls, so only capture them
// when the URL starts with the / character.
jQuery(document).ready(function($) {
$('#chatter-container').contents().on('click', 'a', function(e) {
if($(this).attr('href').charAt(0) == '/') {
e.preventDefault();
top.window.location.href = $(this).attr('href');
}
});
});
</script>
<div id="chatter-container">
<chatter:feed entityId="{!$User.Id}" />
</div>
</apex:page>
<apex:page controller="CustomPage" showHeader="false" sidebar="false" standardStylesheets="false">
<html lang="en">
<head>
<!-- HTML Head content, simplified for example purpose -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row">
<apex:iframe id="chatter-iframe" src="{!$Page.ChatterPage}" width="100%" height="600px" scrolling="true" />
</div>
</div>
</body>
</html>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment