Skip to content

Instantly share code, notes, and snippets.

@willwright82
Last active August 29, 2015 14:03
Show Gist options
  • Save willwright82/de310e0dcbb3327225ad to your computer and use it in GitHub Desktop.
Save willwright82/de310e0dcbb3327225ad to your computer and use it in GitHub Desktop.
iFrame CSS with timer — requires Jquery
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
var frameListener;
$(window).load(function () {
frameListener = setInterval("frameLoaded()", 50);
});
function frameLoaded() {
var frame = $('iframe').get(0);
if (frame != null) {
var frmHead = $(frame).contents().find('head');
if (frmHead != null) {
clearInterval(frameListener); // stop the listener
frmHead.append($('style, link[rel=stylesheet]').clone()); // clone existing css link
//frmHead.append($("<link/>", { rel: "stylesheet", href: "/styles/style.css", type: "text/css" })); // or create css link yourself
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment