定期自动重定向到其他页面 [英] Auto redirecting to another pages at regular intervals
问题描述
我想用PHP创建一个应用程序.
I want to create an application in PHP.
概念非常简单,我只想按固定的时间间隔自动自动加载每个页面. 例如,如果我输入到facebook.com,它将是自动随机加载profile.php,notifications.php,messages.php等...我不确定它的实用性.所以我的问题可能很愚蠢,但我需要帮助.我只知道仅用于刷新页面的元刷新.
concept is very simple, I want to just auto load every page randomly at a regular intervals. For example, if I entered to facebook.com, it would be auto load randomly profile.php, notifications.php, messages.php etc... I am not sure about its practicality. So my question may be stupid, but I need help. I only know meta refresh which is only for refreshing the page.
<meta http-equiv="refresh" content="5; url=http://example.com/">
但是我认为,使用循环,我的概念会起作用.但是我不知道循环如何与元标记一起工作.
But I think, using the loop , My concept will work. But I have no idea how loop will work with meta tag.
推荐答案
我终于得到了解决方案,
I finally got the soloution,
<script>
var interval = 5; // in seconds
var pages = [
'http://website.com/link1.php',
'http://website.com/link2.php',
'http://website.com/link3.php'
];
var current_page_index = 0;
setInterval(function() {
loadintoIframe('myframe', pages[current_page_index]);
current_page_index = (current_page_index + 1) % pages.length;
}, interval * 1000); // second setInterval param is milliseconds
</script>
这篇关于定期自动重定向到其他页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!