开发者

greasemonkey: addEventListener questions

I've a userscript as the following:

document.addEventListener('click', alert('hello monkey'), true);

There were two problems:

  1. "hello monkey" is alerted only when refreshing the browser, not work when clicking window.

  2. 开发者_Go百科

    using GM's 'manage user script' to edit the script, the change doesn't happen. (The source code on the local disc was changed.)


You need to bind it so it isn't executed automatically...

document.addEventListener('click', function(){alert('hello monkey')}, true);

Not sure about #2 though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜