douqianxun8540 2014-03-10 13:47
浏览 36
已采纳

PHP显示url并重定向到下一个循环

I have array [1, 2, 55, 76, ...]

where I generate urls

www.example.com/id/1
www.example.com/id/2
www.example.com/id/55
...

Question: How to show each url for few second (3s) and redirect to next url?

My idea: use of iframe / jQuery

I am open to ideas/code/suggestions.

  • 写回答

2条回答 默认 最新

  • dongluxin2452 2014-03-10 14:06
    关注

    Here's a JS solution. All URIs are written into an array by PHP, then a JS interval cycles through them:

    var urls = ['www.example.com/id/1','www.example.com/id/2','www.example.com/id/55'];
    
    var current = 0;
    var interval = window.setInterval(function(){
        document.getElementById('container').innerHTML = urls[current];
        current += 1;
            if(!urls[current]) {
            window.clearInterval(interval);
        }
    }, 1000);
    

    On the PHP side the first line will look like this ($uris is an array with all URIs):

    echo "var urls = ['".implode("','", $uris)."']";
    

    Here's a JSFiddle example.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题