完成加载外部页面

时间:2015-10-21 12:03:04

标签: javascript jquery html

完成加载后我可以显示页面吗?

1)打开我的页面。
2)开始加载外部页面 3)通过window.location

打开外部页面

我需要一个加载页面且没有iframe的事件。 P.s:页面已满载(DOM和所有图像)。

1 个答案:

答案 0 :(得分:0)

如果你使用的是jQuery,你可以这样做。

// JS
$(function(){

    var external_page =  $('#external_page');

    external_page.ready(function(){

        // This will be executed when the iframe is done loading.
        alert('Page is done loading');

        window.location.href = external_page.attr('src');
    });
});

 <!-- HTML -->
<iframe src="http://api.jquery.com" id="external_page"></iframe>

 /* CSS */
 iframe#external_page {display: none;}
相关问题