Last active
August 29, 2015 14:03
-
-
Save willwright82/de310e0dcbb3327225ad to your computer and use it in GitHub Desktop.
iFrame CSS with timer — requires Jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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