Search code examples
nwjs

nwjs migrating from 0.12 to 10.18


I am facing a problem upgrading from nw.js version 0.12 to 0.18.

I have a situation while I start from the index.html file from the .nw package. From the file, I navigate to my online version of the app by navigating to the link mytestapp.com/page1online.html. From the Online version of the page located at mytestapp.com/page1online.html, I want to navigate back to an HTML page in the .nw package called page1offline.html. The page1offline.html is located in the root of the .nw package.

In nw.js version 0.12, I used the app:// protocol to navigate to any page located inside the .nw package. Now, since it has been deprecated and instead chrome-extension:// was introduced this navigation is broken.

I tried the using chrome-extension:// instead to the app:// but it did not work. Tried the file:// option but that too did not yield the desired result. Also tried many other options but was disappointed.

Can somebody please help me how to navigate to a static HTML file located inside the .nw package from the live online page opened from the nw.js application.

Any help would be highly appreciated.

Thanks in advance.

Regards & Happy Thanksgiving.


Solution

  • The solution to use/navigate/redirect to an HTML resource in an NW package from a hosted HTML page is to have this entry in the package.json file.

    "web_accessible_resources": [ "*.html" ] }

    Also, to reference the resource we should use the chrome-extension protocol as window.location.href = "chrome-extension://" + chrome.runtime.id + "/mytestpage.html"

    Wasted lot of my time on this. Hope this helps someone.