开发者

Script to control own browser

开发者 https://www.devze.com 2022-12-19 04:56 出处:网络
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 t

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 gre开发者_如何学编程asemonkey 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!


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消