2013-02-26 118 views
0

我試圖使一個附加組件來發送一個網站,我是開放的URL,獲取當前URL

function xxxx() 
{ 
a = "mailto:[email protected]?subject= xxxxxxxxxxxxxxxxxx" + document.title; 
a += "&body=" + escape("url" + window.location.href); 
window.location.href = a; 
} 

但似乎是

「鉻:/ /瀏覽器/內容/ browser.xul「< <覆蓋在chrome.manifest

有沒有解決方案或任何其他方式來解決這個問題?

+0

這是Chrome瀏覽器特有的。您需要獲取活動選項卡的URL。 – Blender 2013-02-26 07:36:35

回答

0

對於大多數瀏覽器:

document.URL 

對於一些版本中,如果FF:

window.location.href 
1
document.URL 

或者

location.href 

更多瀏覽器的支持。

window.location object on MDN

+0

問題是爲什麼在文件「chorme.manifest」中出現的URL鏈接是覆蓋網址「chrome:/ browser/content/browser.xul」?不是我打開的網址 – 2013-02-26 07:50:07

0

利用這個jQuery中

$(location).attr('href'); 

或在Javascript

alert(window.location); 

希望這有助於

+0

問題是爲什麼顯示的URL鏈接是覆蓋URL「chrome:/ browser/content/browser.xul」在文件「chorme.manifest」?不是我打開的網址。 – 2013-02-26 07:47:59

0

這裏有檢索使用Javascript和JQuery

URL路徑的一些方法
//jquery 
$(location).attr('href'); 

//pure javascript 
var pathname = window.location.pathname; 

欲瞭解更多信息,請參閱本博客文章:http://www.jquery4u.com/snippets/jquery-current-page-url/

謝謝

拉胡爾·帕蒂爾

+0

我剛剛從這裏得到了答案http://stackoverflow.com/questions/9555997/browser-extension-how-to-get-the-current-pages-url – 2013-02-26 08:21:44