如何用加载图像显示刷新Iframe url

How to refresh the Iframe url with Loading Image display

本文关键字:刷新 Iframe url 显示 图像 何用 加载      更新时间:2023-09-26

我想让I- frame加载它的源页面。我通过使用如下的JavaScript代码部分实现了我的目标

function reloadIt()
{
    frm=document.getElementsByName("pagers")[0];      //we get the iframe object
    frm.src=frm.src;        //or you can set the src to a new src
    setTimeout("reloadIt()",100000);         //the function will run every 60000 miliseconds, or 60 seconds
}

我的HTMl Body代码在这里

<body onload="reloadIt()">

和我的IFRAME代码是这样的

<div id="divLoading">
    <div style="width:100%; height:200px; align="center"> 
        <img src="loader.gif" alt="" align="absmiddle"/> 
    </div>
</div>
<div id="divFrameHolder" style="display:none">
    <iframe  src="lead.php" height="450px;" width="100%"  name="pagers"  onload="hideLoading()" > </iframe>`
</div>

,当这个html页面第一次加载时,我们可以看到在Iframe中加载图像,直到它的源页面加载。但是在时间间隔后,当IFrame刷新时,没有加载图像,它只是重新加载其源页面…有人能帮我吗?

你可以看看BlockUi,一个jquery插件。(http://jquery.malsup.com/block/元素)。试试这样做:

function reloadIt() {
       $("#iframeholder").block({
            message: '<img src="css/ajax-loader.gif"/>',
            css: { width: "600px;", height: "400px;" }
        });
        $('#pagers').attr('src', $('#pagers').attr("src"));
        $('#iframeholder').unblock()
        setTimeout("reloadIt()", 5000);
}