Skip to content

Instantly share code, notes, and snippets.

@morr
Created March 11, 2012 08:36
Show Gist options
  • Save morr/2015619 to your computer and use it in GitHub Desktop.
Save morr/2015619 to your computer and use it in GitHub Desktop.
Содержимое ифрейма
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<h2>inner</h2>
<script>
jQuery(function() {
if ('parent' in window && window != window.parent && 'postMessage' in window.parent) {
window.parent.postMessage('page_change:20', '*');
}
});
$(window).bind('message', function(e) {
$(document.body).append('<h2>remote message from '+e.originalEvent.origin+': "'+e.originalEvent.data+'"</h2>');
var css_match = e.originalEvent.data.match(/^include_stylesheet:(.*)$/)
if (css_match.length == 2) {
var tag = document.createElement('link');
tag.href = css_match[1];
tag.setAttribute('media', 'screen');
tag.setAttribute('type', 'text/css');
tag.setAttribute('rel', 'stylesheet');
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(tag, s);
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment