简体   繁体   中英

reading the current url of a tab

I need to read the browsers URL (specefic to the tab) using javascript. I tried the

var currentURL = window.location; 
alert(currentURL.href) ; 

It shows chrome://browser/content/browser.xul instead of the web address. What should I do to get the web address?

Can someone please help me out with this.

Thanks!

document.location.href或window.location.href必须有效!

Probably already got the answer to this, but simply using document.URL will get you the tab's URL.

javascript:(alert(document.URL))

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