开发者

javascript (in Firefox addon) stop page load

First off: Everything works, but I would like to fine tune this a little.

Basically, in my FireFox addon I have this code in function A:

timervar = setTimeout(function() { quick.redirectToAnotherUrl(); },1500);

and in the redirecttoanotherurl function I have this:

window.content.location.href = FilterUrl;

The problem is the page loads before the redirect takes effect. Is there anyway to stop the page loading totally and then redi开发者_如何转开发rect as normal?


I'm not sure of the browser compatibility, but maybe try window.stop(); before your setTimeout?

For IE, you may need document.execCommand('Stop'); in addition, because as far as I know, it does not support window.stop().


You have a 1.5s delay specified in your argument to setTimeout.

In fact, if you want an immediate redirect, I don't understand why you're using setTimeout at all.

Just set window.content.location.href immediately.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜