---
title: "判断 iframe 是否加载完成的完美方法 "
author: "wuhui"
date: "2010-12-16T16:45:45Z"
tags: []
categories: ["Web前端"]
slug: "iframe"
draft: false
lastmod: "2010-12-16T16:45:45Z"
id: 844757
url: "https://wuhui.iteye.com/blog/844757"
---

var iframe = document.createElement("iframe");  

 iframe.src = "http://www.baidu.com";  

  

 if (iframe.attachEvent){  

    iframe.attachEvent("onload", function(){  

        alert("Local iframe is now loaded.");  

     });  

 } else {  

     iframe.onload = function(){  

         alert("Local iframe is now loaded.");  

    };  
 }  

    

 document.body.appendChild(iframe);