Получить URL вкладки, которая называется Inject-скрипт - PullRequest
1 голос
/ 16 января 2012

Есть проблема.
Я хочу получить URL вкладки с именем inject-script content.js:

Мой manifest.json :

{  
  "background_page": "background.html",  
  "content_scripts": [ {  
    "all_frames": true,  
    "matches": [ "http://*/*", "https://*/*" ],  
    "js": [ "content.js" ],  
    "run_at": "document_start"  
  } ],  
  "description": "Test...",  
  "name": "TestExt",  
  "permissions": [ "tabs", "http://*/*", "https://*/*" ],  
  "version": "0.1.0"  
}  

My content.js :

document.addEventListener("beforeload", function(event) {
  console.log(document.location.href);
}, true);  

Результат по ссылке http://ya.ru:

http://ya.ru/  
http://kiks.yandex.ru/system/fc06.html  
http://suggest.yandex.ru/jquery-1-4-2.crossframeajax.html   

но мне нужно это увидеть

http://ya.ru/  
http://ya.ru/  
http://ya.ru/  

1 Ответ

1 голос
/ 17 января 2012

Попробуйте window.top.document.location.href.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...