I can think of the following methods:
Method 1: jQuery load ()
Js Code
- Var frm = document. getElementById ('myiframe ');
- $ (Frm). load (function () {// and other iframe loaded
- Dosomething ();
- });
Method 2: onreadystatechange
Js Code
- Var iframe = document. createElement ("myiframe ");
- Iframe. src = "http://www.baidu.com ";
- If (! /* @ Cc_on! @ */0) {// condition comment for IE if it is not IE
- Iframe. onload = function (){
- Alert ("Local iframe is now loaded .");
- };
- } Else {
- Iframe. onreadystatechange = function () {// All nodes under IE have onreadystatechange.
- If (iframe. readyState = "complete "){
- Alert ("Local iframe is now loaded .");
- }
- };
- }
- Document. body. appendChild (iframe );
Method 3: attachEventJs code
- Var iframe = document. createElement ("iframe ");
- Iframe. src = "http://www.baidu.com ";
- If (iframe. attachEvent ){
- Iframe. attachEvent ("onload", function () {// IE
- Alert ("Local iframe is now loaded .");
- });
- } Else {
- Iframe. onload = function () {// non-IE
- Alert ("Local iframe is now loaded .");
- };
- }
- Document. body. appendChild (iframe );