我的一位同事需要来自第三方网站的一份数据。这些数据每天早上的任意时间都会发布到网站上。他必须坐在那里,每 10 秒在浏览器中单击一次刷新,直到它显示出来。他问我是否可以写一些东西让该页面每 X 秒自动刷新一次,这样他就可以在一台显示器上保持打开状态,并在另一台显示器上做一些其他工作。
通常,我会用 Perl 写一个小屏幕抓取工具,并在它出来时通过电子邮件将他想要的号码发送给他...但我认为编写一个小书签可能会很有趣。
我得到了这样的信息:
javascript:(function(){setInterval("location.reload(true);",10000);})()
但无法弄清楚如何在页面重新加载后使效果持续存在。是否可以?如果是这样...怎么办?
这在 Firefox/Greasemonkey 中很容易...但这家伙却被困在运行 IE6 的锁定版本中。他可以安装一个小书签,但无法安装相当于 GM 的 IE(如果存在)
请在此处为我指出正确的方向...重新加载页面后是否有可能让 Javascript 保留下来?
One of my coworkers needs a piece of data from a 3rd party website. That data gets posted to a site each morning at an arbitrary time. He has to sit there and click refresh in his browser every 10 seconds until it shows up. He asked me if I could write something to make that page auto refresh every X seconds so he can leave it open on one monitor and do some other work on the other.
Normally, I would write a little screen scraper in perl and email him the number he wants when it comes out... But I thought it might be fun to write a bookmarklet.
I got as far as this:
javascript:(function(){setInterval("location.reload(true);",10000);})()
But cannot figure out how to make the effect persist after the page reloads. Is it possible? If so... how?
This would be easy in Firefox/Greasemonkey... but this guy is stuck running a locked-down version of IE6. He can install a bookmarklet, but cannot install the IE equivalent of GM (if that even exists)
Please point me in the right direction here... is it possible to have Javascript persist after reloading a page?
发布评论
评论(3)
您可以尝试使用 AJAX 来获取页面,然后将当前正文的
innerHTML
替换为新正文。You could try some AJAX to GET the page, then replace the
innerHTML
of the current body with the new body.您可以尝试让书签打开一个新窗口并写入该窗口的内容以通过类似
window.opener.document.location.reload();之类的方式重新加载父窗口。
You could try having the bookmarklet open a new window and writing the content of that window to reload the parent via something like
window.opener.document.location.reload();
不确定是否有书签,但这个示例会每隔一段时间刷新页面上的 Iframe,这应该可以解决问题...
Not sure about a bookmarklet, but this examples refreshes an Iframe on the page at an interval, which should do the trick...