Many times we use the iframes in site for loading the some extra content. Some time we need trigger events when iframes are loaded completely in browser. Here we check iframes loaded.
iframes are loaded completely in browser
In webpage loading Iframe and controlling site UI is very important.
This script is able to check local or cross domain iframe is loaded or not.
I tested following script with various browsers and OS. So there is no cross browser issue.
[viral-lock message=”Code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
var iframe = document.createElement("iframe"); iframe.src = "https://purabtech.in/"; if (navigator.userAgent.indexOf("MSIE") > -1 && !window.opera){ iframe.onreadystatechange = function(){ if (iframe.readyState == "complete"){ alert("Iframe is now loaded."); } }; } else { iframe.onload = function(){ alert("Iframe is now loaded."); }; }
[/viral-lock]
Have fun!
good
This works, thank you! Nice to be able to check to see if the iFrame loads and give users a correct error message when things go wrong.