IFRAME动态加载触发onload事件

原文地址:http://blog.ops.cc/webtech/javascript/f5nhm.html

 

<body>



    <script>var iframe = document.createElement("IFRAME");



        document.body.appendChild(iframe);



        iframe.src = "http://www.ops.cc";







        if (iframe.attachEvent) {



            iframe.attachEvent("onload", function () {



                alert("Local iframe is now loaded.");



            });



        } else {



            iframe.onload = function () {



                alert("Local iframe is now loaded.");



            };



        }



    </script>



</body>

 

你可能感兴趣的:(iframe)