Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome Chrome扩展:在Chrome.tabs.update之后访问DOM_Google Chrome_Google Chrome Extension - Fatal编程技术网

Google chrome Chrome扩展:在Chrome.tabs.update之后访问DOM

Google chrome Chrome扩展:在Chrome.tabs.update之后访问DOM,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我的目标是按id搜索div,如果它存在于我的站点支持的所有语言中 manifest.json { "manifest_version": 2, "name": "Hello World!", "description": "This extension is to check if link is not visible when it should not :)", "version": "1.0", "browser_action": { "default_icon": "icon

我的目标是按id搜索
div
,如果它存在于我的站点支持的所有语言中

manifest.json

{
"manifest_version": 2,

"name": "Hello World!",
"description": "This extension is to check if link is not visible when it should not :)",
"version": "1.0",

 "browser_action": {
  "default_icon": "icon.png",
  "default_popup": "popup.html"
 },

"content_scripts": [ {
    "js": [ "jquery-1.11.1.min.js"],
    "matches": [ "http://*/*", "https://*/*"]
}],

  "permissions": [
    "tabs",
    "http://*/*",
    "https://*/*"
]

 }
popup.html
-

 <html>
 <script type="text/javascript" src="jquery-1.11.1.min.js"></script>
 <style>

   table{background:#CCC;border:1px solid #000;}
   table td{padding:15px;border:1px solid #DDD;}
 </style>
 <body>
 <input type="hidden" id="currentLink"/>
 <hr />

    Checking ...

  <div id="dynamictable"></div>
   <script type="text/javascript" src="currentUrl.js"></script>
  </body>
  </html>

在上面的中,查询不来。chrome.tabs.update之后如何解析DOM?

您尝试过使用回调吗?
api将函数定义为
chrome.tabs.update(整数tabId、对象更新属性、函数回调)

也许你可以改变

chrome.tabs.update(tab.id, {active:true, url:  currentTab + "?languageParam=" + languages[i]});
为了

这可能不起作用,但我希望这个想法是明确的

chrome.tabs.update(tab.id, {active:true, url:  currentTab + "?languageParam=" + languages[i]});
chrome.tabs.update(
    tab.id,
    {active:true, url:  currentTab + "?languageParam=" + languages[i]},
    function() { // this is the callback you may want to use.
        var query = document.querySelector("div#header");
        if (query) {
            alert("This page has a friendly div");
        }
    }
);