定期自动重定向到其他页面 [英] Auto redirecting to another pages at regular intervals

查看:56
本文介绍了定期自动重定向到其他页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆