In a Firefox Addon I delegate the User to a new URL through
window.content.wrappedJSObject.location = 'http://newlocation/';
What I am 开发者_如何学运维asking for is a load event
binding for the site-change. I tried
window.content.addEventListener('load', function() { });
.. which won't work.
Does this example cover what you want: On page load ?
If not, you have to specify further what you mean.
Make sure you actually look at the error messages. Ctrl-shift-J is your friend! In this case addEventListener
requires a 3rd boolean parameter: window.content.addEventListener('load', function() { }, true);
or window.content.addEventListener('load', function() { }, false);
. This indicates whether you want the listener to be called during the bubbling phase or the capture phase. In most cases, it doesn't matter which one you use, except (IIRC) the load
event doesn't bubble so you have to use the capturing phase (true
).
精彩评论