Skip to content

Instantly share code, notes, and snippets.

@mike-gusiev
Created September 8, 2015 16:26
Show Gist options
  • Save mike-gusiev/963ebd5e24644099fac5 to your computer and use it in GitHub Desktop.
Save mike-gusiev/963ebd5e24644099fac5 to your computer and use it in GitHub Desktop.
<iframe id="nascar_frame" frameborder="0" height="5700" scrolling="no" src="http://chasehub.azurewebsites.net/"></iframe>
<script type="text/javascript">
(function ($) {
$(window).scroll(function() {
var topPosition = $(window).scrollTop();
if($('#nascar_frame')) {
$('#nascar_frame')[0].contentWindow.postMessage('nascar_' + topPosition, 'http://chasehub.azurewebsites.net/');
}
});
})(jQuery);
</script>
<!-- within iframe -->
<script>
window.addEventListener('message', function(e) {
var message = e.data.split('_');
if(message.length) {
var topPosition = message[1];
topPosition -= 260;
$('.popup').css('top', topPosition + 'px');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment