JavaScript Show Loading Gif While Iframe Loads
I need a loading GIF to show up while the iframe is loading. This is what I came up with:
Copy
<img id="img" src="images/loader.gif"/></div>
<script>
window.onload = function(){
document.getElementById('img').style.display = "none";
}
</script>
Solution 2:
iframes
are not allowed to just access parent content willy-nilly. Suppose a hacker finds a vulnerability in your page (say, you have a comment form that allows iframe
s for whatever purpose. If they can just access the parent, they get to walk all over your site.
You could use instead postMessage
. Because both the page and the iframe now agree on how to communicate, and what constitutes valid communication, you don't have arbitrary access to your page. There's a good tutorial at http://robertnyman.com/2010/03/18/postmessage-in-html5-to-send-messages-between-windows-and-iframes/
Post a Comment for "JavaScript Show Loading Gif While Iframe Loads"