2010-03-11 119 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))