Skip to content

Instantly share code, notes, and snippets.

@KobaKhit
Last active June 13, 2019 21:13
Show Gist options
  • Save KobaKhit/a3d265aab2a006dcf5a8e11f7a525e8e to your computer and use it in GitHub Desktop.
Save KobaKhit/a3d265aab2a006dcf5a8e11f7a525e8e to your computer and use it in GitHub Desktop.
Create dynamic embed in visual force which displays information by user
<apex:page >
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!-- User Id in a span -->
<span id = 'user' style = 'display: none;'>
<apex:outputText label="Account Owner" value="{!$User.Id}"></apex:outputText>
</span>
<!-- Embed placeholder -->
<iframe id = 'embed' src="" width="100%" height="1200" frameborder="0">
<p>
<a href="https://developer.mozilla.org/en-US/docs/Glossary">
Fallback link for browsers that don't support iframes
</a>
</p>
</iframe>
<script>
// var user = document.getElementById('{!$Component.user}').innerHTML;
// get user id
var user = $.trim($('#user').text());
console.log(user)
// url of the embed with a url parameter
var url1 = "https://metabase76.herokuapp.com/question/14?id="+user2
console.log(url1)
$('#embed').attr('src', url1) // assign url to iframe
// update user by manually passing user ID # need formsubmit hmlt element
function update_user() {
user2 = $('#rep').val();
var url1 = "https://metabase76.herokuapp.com/question/14?id="+user2
console.log(url1)
$('#embed').attr('src', url1)
}
</script>
</html>
</apex:page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment