Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/449.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
Javascript Chrome扩展无法与window.open一起使用_Javascript_Html_Google Chrome_Google Chrome Extension_Window.open - Fatal编程技术网

Javascript Chrome扩展无法与window.open一起使用

Javascript Chrome扩展无法与window.open一起使用,javascript,html,google-chrome,google-chrome-extension,window.open,Javascript,Html,Google Chrome,Google Chrome Extension,Window.open,我正在编写一个chrome扩展,它需要修改弹出窗口的html,该窗口会弹出javascript代码,如下所示: var myWindow = window.open("", "MsgWindow", "width=200, height=100"); myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>"); 当我打开一个普通网页时,我会看到一个标题为的警

我正在编写一个chrome扩展,它需要修改弹出窗口的html,该窗口会弹出javascript代码,如下所示:

var myWindow = window.open("", "MsgWindow", "width=200, height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
当我打开一个普通网页时,我会看到一个标题为的警告对话框。但是,当我使用javascript代码
窗口.open
时,没有警报

我怎样才能让扩展也在弹出页面上工作


谢谢

尝试包含您的
窗口。在清单中的
JS
数组中打开
JS文件。window.open位于另一个网页上,而不是扩展的一部分。抱歉,如果这是不明确的,如果它不是扩展的一部分,它如何运行?用户单击一个按钮,打开弹出窗口。我希望扩展在新打开的窗口上运行。请查看以下内容:
{
    "name":"PresentIT",
    "description":"Connects Google Drive to PresentIT",
    "version":"0.1",
    "manifest_version":2,
    "content_scripts": [
    {
        "matches": ["<all_urls>"],
        "js": ["script.js"]
    } ]
}
alert(document.title);