2010-07-01 59 views
0

我有两个网址,我阅读并送入使用IFRAME SRC值的数组:IFRAME SRC价值变化不刷新的iframe在IE6

document.getElementById("iframe").src = unescape(dashboard.url); 

紧随此行之后,我发出警报(文件。 getElementById(“iframe”).src),这一切工作正常。

我的问题是,数组中的第一个URL似乎正确加载,并且警报显示正在使用的iframe正确的URL。

但是,当第二个URL出现在iframe src值中时,警报显示正确的URL,但是我的iframe在同一页面上没有被正确的URL刷新,因此仍然显示我以前工作的数组中的第一个URL。

我错过了什么 - 这是一种IE6的错误,因为我可以看到,iframe第二次没有被调用。

我注意到了这一点,把一个onLoad =“alert('Test');”在我的iframe中,它只出现一次,而不是第二次URL的第二次。

任何想法?

顺便说一句,我使用setTimeout()调用来循环访问数组。

谢谢。

回答

0

See it in action.(作品X-浏览器)

<iframe id="rotator" src="http://...first"></iframe> 

<script> 
// start when the page is loaded 
window.onload = function() { 

    var urls = [ 
    "http://...first", 
    "http://...second", 
    // .... 
    "http://...tenth" // no ,!! 
    ]; 

    var index = 1; 
    var el = document.getElementById("rotator"); 

    setTimeout(function rotate() { 

    if (index === urls.length) { 
     index = 0; 
    } 

    el.src = urls[index]; 
    index = index + 1; 

    // continue rotating iframes 
    setTimeout(rotate, 5000); 

    }, 5000); // 5000ms = 5s 
}; 
</script> 
+0

谢谢,但真的不回答我了。 – tonyf 2010-07-01 23:23:13

+0

嗨,你是否能够尝试你的旋转器与扩展名为“.xml”的网址,并请让我知道它是否工作 - 谢谢。 – tonyf 2010-07-02 06:27:19

+0

您可以尝试一下,我发布的示例可以修改:http://jsbin.com/ucika/3/edit(编辑代码并单击预览) – galambalazs 2010-07-02 14:22:41