I have a great bookmarklet that reloads the css for the projects I'm working on. Right now I need to click the bookmark every time I want it to reload. What I want it to do is just set an interval.
This is it:
javascript:void(function(){var i,a,s;a=document.g开发者_StackOverflowetElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})();
This is what I tried:
javascript:void(
setInterval(
function(){
var i,a,s;
a=document.getElementsByTagName('link');
for(i=0;i<a.length;i++){
s=a[i];
if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {
var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');
s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())
}
}
}, 500
);
)();
Any ideas? I've never worked with bookmarklets.
Thanks!
I'd try to name the function then pass it to setInterval
:
javascript: myfun = function() {...}; setInterval(myfun, 500);
精彩评论