0

I have a problem about Open dialog from javascript file (config in content_script). I use "chrome.windows.create" and have error: "Cannot read property 'create' of undefined". Have you any idea? Thanks you very much! My source:

**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>

1 Answer 1

1

chrome.windows.* can't be accessed in content scripts, you would need to move that logic to popup page or background page.

  1. Rename background.html to popup.html. The previous name indicates that maybe you are confused about background page and popup page.
  2. Add background page.
  3. Move your myJS logic to background page.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you for your reply. However, I must use content scripts. My problem is show dialog from content script (myJS.js).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.