window.打开多个设置间隔的图像循环
window.open multiple setintervals images loops
我的Intervals有3个问题。
一个是我的内部只显示两张图片,而我正试图显示4张。我试图复制我的函数,并将<img />
更改为doc.write(didn't work)
。
最后,我如何从这些间隔中创建一个循环(显示1,2,3,4)nostop。它需要将所有图像显示到window.open中。(有什么建议吗:创建一个<img />
数组更好吗?)
<script type="text/javascript" >
var OpenWindow = window.open("http://vrjournal.com/adtech-new-york-showcases-virtual-realitys-move-into-mobile-advertising","","top=100, left=400,resizable=yes,height=550,width=550,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
Update1();
function Update1() {
OpenWindow.document.write("<IMG float:'center' SRC='Oculus.jpg'>");
setInterval("Update2();",3000);
}
function Update2() {
OpenWindow.document.write("<IMG float:'center' SRC='future-vr.jpg'>");
setInterval("Update1();",3000);
}
</script>
如果您打开的窗口与代码所在的页面位于同一个域上,那么您可以创建一个图像URL数组,并在每个计时器上对URL进行索引。
<script type="text/javascript" >
var OpenWindow = window.open("http://vrjournal.com/adtech-new-york-showcases-virtual-realitys-move-into-mobile-advertising","","top=100, left=400,resizable=yes,height=550,width=550,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
var imgURLS = ['Oculus.jpg', 'future-vr.jpg', 'img3.jpg', 'img4.jpg'];
var imgIndex = 0;
var timer = setInterval(function() {
if (imgIndex >= imgURLS.length) {
// done with the array of images, stop the timer
clearInterval(timer);
} else {
OpenWindow.document.write('<img src ="' + imgURLS[imgIndex++] + '">');
}
}, 3000);
</script>
如果您打开的窗口与代码所在的页面位于不同的域中,则由于同源安全保护,浏览器将不允许您修改其他窗口。
以下是我试图为这些图像生成一个无限循环的操作。
<script type="text/javascript" >
var OpenWindow = window.open("","","top=100, left=400,resizable=yes,height=550,width=550,menubar=yes,location=yes,resizable=yes,scrollbars=yes");
var imgURLS = ['Oculus.jpg', 'future-vr.jpg', 'morpheus.jpg', 'samsungvr.jpg'];
var imgIndex = {
for (var i = 0; i < imgURLS.length; i++) {
for (var j = 0; j < imgURLS.length; j++)
};
var timer = setInterval(function() {
if (imgIndex > imgURLS.length) {
clearInterval(timer);
} else {
OpenWindow.document.write('<img src ="' + imgURLS[imgIndex++] + '">');
}
}, 3000);
</script>
相关文章:
- 循环浏览多个身体背景图像
- 使用javascript的图像替换循环
- 在ng重复循环中显示来自不同文件夹的图像
- JavaScript中的数组图像循环
- 循环以检查数组中的最后一个图像
- javascript背景图像位置循环
- jQuery循环寻呼机附加较小的图像大小
- 每第n个图像具有下一个循环的余数偏移
- Jquery图像循环问题
- jQuery 单循环图像循环
- Javascript图像循环器
- 如何在页面上的多个缩略图集的鼠标悬停时实现 jQuery 图像循环
- 寻找一种在一个页面上运行多个图像循环仪的方法
- window.打开多个设置间隔的图像循环
- 图像循环加载不到位
- 更改图像,点击(6图像循环)
- 图像循环-重新循环
- 褪色图像循环jQuery
- 如何添加onclick到简单的js图像循环
- jQuery动画制作幻灯片图像循环在同一个方向上迭代