0
我有一个关于JavaScript文件(配置在content_script中)打开对话框的问题。我使用“chrome.windows.create”,并有错误:“无法读取未定义的属性”创建“。你有什么想法吗? 非常感谢! 我来源:Chrome扩展 - 从JavaScript文件打开对话框(在content_script中的配置)
**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>
\t <meta charset="utf-8" />
</head>
<body>
<button id="btnSubmit" >Submit</button>
<button id="btnCancel" >Close</button>
</body>
</html>
感谢您的回复。但是,我必须使用内容脚本。我的问题是来自内容脚本(myJS.js)的显示对话框。 –