dtjo51649 2010-02-07 09:04
浏览 9

脚本控制自己的浏览器

So I'm trying to debug my website... basically what I need to do is write a script that will periodically follow a link on my page, but I need to see the result in my browser which is why I need it to happen in the browser. I want it to click on the same link every few seconds without any human interaction. The resulting page each time will have the same structure as the last, so the link will have the same attributes and everything... which leads me to think I can probably use Javascript for this task, but I'm not sure how. Maybe greasemonkey in firefox? The problem is the only language I'm any good at is PHP and I can't think of any solution using that. One thing I'd like to do with it is make it do it at pseudo-random intervals... like between 15 seconds and 60 seconds... That's why I think I need a script rather than an existing program or something... So if anyone has any ideas, thanks!

  • 写回答

1条回答 默认 最新

  • donglou1866 2010-02-07 09:56
    关注

    You can also use JavaScript to refresh the page automatically after a given time period. Here, we are refreshing the page 5 seconds after the page loads. This results in the page continuously refreshing every 5 seconds.

    <html>
    <head>
    <script type="text/JavaScript">
    <!--
    function timedRefresh(timeoutPeriod) {
        setTimeout("location.reload(true);",timeoutPeriod);
    }
    //   -->
    </script>
    </head>
    <body onload="JavaScript:timedRefresh(5000);">
    <p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
    <p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
    </body>
    </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料