I am working on a Firefox extension. For this I need the current URL. I tried both 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
windowelement for the current web page, you can usewindow.content.So you can get the location via
window.content.location.href.