0

I am making a Chrome app that has the user open a new page when the user clicks on the app in the top-right corner. I am trying to have Chrome open a new page when the app loads.

Here is my manifest.json file:

{
  "name": "My App That Opens in a New Page",
  "version": "1.0",
  "manifest_version": 2,
  "icons": { "128": "mediumIcon.png" },
  "description": "A practice text editor that opens in a new tab or window.",
  "browser_action": {
    "default_icon": "smallIcon.png",
    "default_popup": "load.html"
  }
}

Subsequently, in load.html, I have tried this HTML to open a new page per the instructions at http://developer.chrome.com/extensions/overview.html.

<!DOCTYPE html><html><head>
  <script type='text/javascript'>window.open('editor.html');</script>
</head><body></body></html>

However, editor.html is not opening when I click on the icon for my app in Chrome. Why not? Doesn't window.open open new windows in javascript? Does it behave differently for javascript embedded in the browser?

dangerChihuahua007
  • 20,299
  • 35
  • 117
  • 206
  • Have you ever tried to look in the console for the error message? I believe that the CSP is preventing the inline script from being executed. – Rob W Sep 05 '12 at 19:42
  • Chrome Console interestingly issues no errors. Thanks though. – dangerChihuahua007 Sep 05 '12 at 19:43
  • The errors will show up upon [inspection of the popup](http://developer.chrome.com/extensions/tut_debugging.html#inspect-popup). Possible duplicate of [Port error while changing chrome extension from manifest v1 to v2](http://stackoverflow.com/questions/11913575/port-error-while-changing-chrome-extension-from-manifest-v1-to-v2/11914797#11914797). – Rob W Sep 05 '12 at 19:44
  • Actually, I just tried a minimal extension, and your code worked fine out of the box. – Nandeep Mali Sep 05 '12 at 20:12
  • @n9986 Can't be. Did you literally copy the manifest file? manifest v2 prevents inline JavaScript from being executed, no exceptions. – Rob W Sep 05 '12 at 20:22
  • I did literally copy. Here is a download link to what I made. http://cl.ly/2o28070y3E3j (just add the icons to the folder) This I loaded into the extension manager and I had a working icon which popped up a new tab. Works. – Nandeep Mali Sep 05 '12 at 20:29
  • @n9986 The new windows does not open - as expected. I guess that you're using Chrome <= 17, which does not recognise the manifest version / content_security_policy keys (introduced in [Chrome 18](http://developer.chrome.com/extensions/whats_new.html#18)). – Rob W Sep 05 '12 at 21:06

0 Answers0