开发者

document.URL vs location.href > no results

开发者 https://www.devze.com 2023-02-14 02:41 出处:网络
I am working on a Firefox extension. For this I need the current URL. I tried bot开发者_Go百科h possibilities with the following result:

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.

0

精彩评论

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