简体   繁体   中英

How to get notified whenever the URL in the address bar changes Firefox JPM

Is it possible to detect whether an URL changes, while developing Firefox addons using the new SDK/JPM?

It's not exactly hashchange what I want to detect, but any changes to the URL, like ajax request changing search terms or things like that.

Is it a way to do it? Thanks.

I came up with a solution which includes using a combination of MutationObserver and "old location value checking".

Basically I implemented a value check on location.href but using a MutationObserver to detect changes in the DOM, instead of using an interval which would kill the performance and waste some precious milliseconds.

Thanks for the contributions. Hope this helps anyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM