如何在页面中循环?

Gre*_*enO 9 html php

这是我最近的任务所面临的挑战.我还没有想出最好的方法,也许别人有个主意.

使用PHP和/或HTML,创建一个以给定间隔循环遍历任意数量的其他页面的页面.

例如,我们将加载此页面,它将需要我们谷歌20秒,然后到雅虎10秒,然后到堆栈溢出180秒等等.

Jon*_*nan 19

<!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>
Run Code Online (Sandbox Code Playgroud)


Jas*_*hen 1

对内容使用单独的 iframe,然后使用 Javascriptdelay()一段时间并设置 iframe 的location属性。