Nw.js: ReferenceError: nw is not defined after changing windows location

Created on 3 Jun 2016  路  2Comments  路  Source: nwjs/nw.js

Verions tested 0.13.4 sdk x64 and 0.14 sdk x 64
OS: Win7

Getting the "ReferenceError: nw is not defined" after changing windows location. The strange thing is that in main.html the win variable is properly initialized with the nw.Window.
untitled

main.html:

<!DOCTYPE html>
<html>
    <head>
        <script>
                win.window.location.assign('http://github.com');
        </script>
    </head>
    <body>        
    </body>
</html>

package.json:

{
  "name": "h2",
  "version": "0.0.1",
  "private": true,
  "main": "main.html",
  "window": {
    "show": true
  },
  "inject_js_start":"./lib/winsave.js"
}

./lib/winsave.js

var win       = nw.Window.get();
console.log('test');

the winsave.js script stops working

Most helpful comment

@angufix Add "node-remote" : "<all_urls>" in your package.json. Check this out for possible node-remote values.

All 2 comments

@angufix Add "node-remote" : "<all_urls>" in your package.json. Check this out for possible node-remote values.

@RohitSharma27 thx,it works!

Was this page helpful?
0 / 5 - 0 ratings