How to check iframes are loaded completely in browser

How to check iframes are loaded completely in browser

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]

 

iframes are loaded completely in browser
iframes are loaded completely in browser

Have fun!

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “How to check iframes are loaded completely in browser”

  1. 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.

Leave a Reply

Your email address will not be published.