开发者

Listen for history events in FireFox?

开发者 https://www.devze.com 2022-12-10 10:11 出处:网络
From the context of a FireFox extension... Is there some way to be notified of back/forward/goto/reload/etc. \"History Events\"?I\'m not looking for a way to cancel or change them, just to be made aw

From the context of a FireFox extension...

Is there some way to be notified of back/forward/goto/reload/etc. "History Events"? I'm not looking for a way to cancel or change them, just to be made aware of them.

My best solution thus far has been to hook into the UI elements responsible (menuitems and buttons) for triggering hi开发者_Python百科story navigation. This obviously doesn't work terribly well in the face of any but the most tightly controlled FireFox installations as all it takes is one extension doing:

gBrowser.webNavigation.goBack()

... to ruin my day, to say nothing of webpages themselves playing games with the history.


You need to implement nsISHistoryListener and register your implementation as a session history listener for the <browser> you're interested in. Googling shows that people have done this already, so you should be able to find extensions that do this to copy their code.

0

精彩评论

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