开发者

OnLoad event not working with Google search on Firefox extension

I'm using an onLoad event on a Firefox extension to detect each time a page is loaded and display a 开发者_开发百科Javascript alert (first example on https://developer.mozilla.org/en/Code_snippets/On_page_load).

I realized it doesn't work well with Google search engine (i.e. If you change your keyword and display a new search there isn't a new Javascript alert displayed).

Does someone know how to make the alert appear each you type one or several keyworks and press "Enter" or click on "Search" ?


Well, you can look for the keyup/keydown event on the search form and filter for Enter (13). And you can watch the click event on the search button(s). That should do what you want, although it would mean pretty tight coupling with Google search, so you would have to update your selector/logic every time Google makes a change to their page.


A simple solution is to use the event "change" in the event listener !

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜