2010-03-11 115 views
0

我需要使用javascript阅读浏览器URL(标签为specefic)。我试过阅读标签的当前网址

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

它显示chrome://browser/content/browser.xul而不是网址。 我应该怎么做才能得到网址?

有人可以帮助我这个。

谢谢!

+0

你的意思是在Firefox的扩展? – YOU 2010-03-11 07:17:13

+3

window.location.href不起作用? – 2010-03-11 07:21:17

+0

+1 @Greg K:你应该在答案中写下这个:) – RubyDubee 2010-03-11 07:42:12

回答

2

document.location.href OR window.location.href must work !!

+0

no @webbish! document.location.href或window.location.href给我以下内容: chrome://browser/content/browser.xul 这是Chrome网址。我需要的是外部Http网址! 关于我螨虫会出错的建议吗? – encryptor 2010-03-11 08:10:40

+0

我试过这个......我得到了正确的URL。 – RubyDubee 2010-03-11 09:45:25

0

可能已经得到了这个答案,但只是使用document.URL会让你的标签的URL。

javascript:(alert(document.URL))