I am working on a Firefox extension. For this I need the current URL. I tried bot开发者_Go百科h possibilities with the following result:
location.href > chrome://browser/content/browser.xul
document.URL > undefined
They are called in the event if a menu button is clicked. Why is it not working?
You are accessing Firefox's DOM, not the web page's one.
To get the window
element for the current web page, you can use window.content
.
So you can get the location via window.content.location.href
.
精彩评论