我如何循环浏览页面? [英] How can I cycle through pages?

查看:92
本文介绍了我如何循环浏览页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我最近承担的一项挑战。我还没有想出实现这一目标的最佳方法,也许有人有一个想法。



使用PHP和/或HTML,创建一个页面,该页面以给定的时间间隔在任意数量的其他页面中循环。



例如,我们会加载这个页面,它会把我们带到谷歌20秒,然后到雅虎10秒,然后在180秒等堆栈溢出,等等。

解决方案

 <!DOCTYPE html PUBLIC -  // W3C // DTD HTML 4.01 // ENhttp://www.w3.org/TR/html4/strict.dtd\"> 
< html lang =en>
< head>
< title>仪表板示例< / title>
< style type =text / css>
body,html {margin:0;填充:0;宽度:100%;身高:100%;溢出:隐藏; }
iframe {border:none; }
< / style>
< script type =text / javascript>
var Dash = {
nextIndex:0,

dashboards:[
{url:http://www.google.com,time:5} ,
{url:http://www.yahoo.com,time:10},
{url:http://www.stackoverflow.com,time:15}
$,

display:function()
{
var dashboard = Dash.dashboards [Dash.nextIndex];
frames [displayArea]。location.href = dashboard.url;
Dash.nextIndex =(Dash.nextIndex + 1)%Dash.dashboards.length;
setTimeout(Dash.display,dashboard.time * 1000);
}
};

window.onload = Dash.display;
< / script>
< / head>
< body>
< iframe name =displayAreawidth =100%height =100%>< / iframe>
< / body>
< / html>


Here's a challenge that I was tasked with recently. I still haven't figured out the best way to do it, maybe someone else has an idea.

Using PHP and/or HTML, create a page that cycles through any number of other pages at a given interval.

For instance, we would load this page and it would take us to google for 20 seconds, then on to yahoo for 10 seconds, then on to stackoverflow for 180 seconds and so on an so forth.

解决方案

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Dashboard Example</title>
<style type="text/css">
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
iframe { border: none; }
</style>
<script type="text/javascript">
var Dash = {
    nextIndex: 0,

    dashboards: [
        {url: "http://www.google.com", time: 5},
        {url: "http://www.yahoo.com", time: 10},
        {url: "http://www.stackoverflow.com", time: 15}
    ],

    display: function()
    {
        var dashboard = Dash.dashboards[Dash.nextIndex];
        frames["displayArea"].location.href = dashboard.url;
        Dash.nextIndex = (Dash.nextIndex + 1) % Dash.dashboards.length;
        setTimeout(Dash.display, dashboard.time * 1000);
    }
};

window.onload = Dash.display;
</script>
</head>
<body>
<iframe name="displayArea" width="100%" height="100%"></iframe>
</body>
</html>

这篇关于我如何循环浏览页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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