我对javascript文件(content_script中的配置)的开放对话框有问题。我使用"chrome.windows.create“并有错误:”无法读取未定义的属性'create‘“。你知不知道?非常感谢你!我的消息来源:
**manifest.json**
{
"name": "ABC",
"short_name": "ABC",
"description": "My tool",
"permissions": [ "contentSettings", "tabs", "http://*/*", "https://*/*" , "https://localhost/*", "https://localhost/*/*", "contextMenus"],
"homepage_url": "http://www.localhost/GMS",
"update_url": "https://clients2.google.com/service/update2/crx",
"manifest_version": 2,
"version": "1.0.4",
"icons": {
"16": "img/icon-16.png",
"48": "img/icon-48.png"
},
"browser_action": {
"default_icon": "img/icon-128.png",
"default_popup": "background.html"
},
"content_scripts": [{
"css": [ "addon_tool.css" ],
"js": [ "jquery.js", "config.js","myJs.js"]
}]
}
**myJS.js**
$.ajax({
type: "POST",
data:{UserName: 'name'},
dataType: "json",
url: "https://localhost/...",
success: function (data) {
alert('OK');
},
error: function (xhr, status, error) {
try {
***chrome.windows.create({ 'url': 'PopupForm.html', 'type': 'popup' }, function (window) {***
});
} catch (e) {
alert(e.message);
}
}
});**PopupForm.html**
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<button id="btnSubmit" >Submit</button>
<button id="btnCancel" >Close</button>
</body>
</html>
发布于 2016-08-04 08:43:57
chrome.windows.* 无法在内容脚本中访问,您需要将该逻辑移动到弹出页或背景页。
background.html重命名为popup.html。前面的名称表示您可能对背景页和弹出页感到困惑。myJS逻辑移到后台页面。https://stackoverflow.com/questions/38762209
复制相似问题