简体   繁体   English

使用JavaScript自动导航到设置的页面列表

[英]Use JavaScript to automatically navigate to a set list of pages

I have created a dashboard which displays real time information for the status of each environment. 我创建了一个仪表板,该仪表板显示每个环境状态的实时信息。

As this is going to be displayed on a large monitor I would like it to automatically switch between a set list of pages, preferably in a JavaScript array. 因为这将在大型监视器上显示,所以我希望它可以在一组页面列表之间自动切换,最好是在JavaScript数组中。

eg. 例如。

["page1.html", "page2.html", "page3.html", "page4.html", ... ] [“ page1.html”,“ page2.html”,“ page3.html”,“ page4.html”,...]

When I am on page1, I would like it to load page2 after a couple of minutes. 当我在page1上时,我希望它在几分钟后加载page2。 After a couple of minutes on page2 I then want it to load page3 etc... 在page2上几分钟后,我希望它加载page3等。

I understand how to do the actual page switch, but I am having trouble with figuring out how to get the page to use the next entry in the array. 我了解如何进行实际的页面切换,但是在弄清楚如何获取页面以使用数组中的下一个条目时遇到了麻烦。

The most simple and convenient method would be, to have or to create an <iframe> element (respectively a new window instance) and remotely access that document from your parent site. 最简单便捷的方法是拥有或创建<iframe>元素(分别是新的window实例)并从父站点远程访问该文档。

So let's say we have an <iframe> , we access that via Javascript in a way like 假设我们有一个<iframe> ,我们可以通过Javascript以类似的方式进行访问

var iframe = document.getElementById('myiframe'),
    pages  = ["page1.html", "page2.html", "page3.html", "page4.html" ];

iframe.src = pages[ 0 ];

All you would have left to do is to implement a Timer-loop using setTimeout or so to iterate through the array entries. 您剩下要做的就是使用setTimeout左右实现Timer-loop ,以遍历数组条目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM