BU0
BU0

Reputation: 762

Open new window in WinJS Universal App

I am trying to figure out how to open a new window from within my WinJS Universal Windows app.

I've found plenty of examples of how to do this in a XAML Universal App using Windows.ApplicationModel.Core.CoreApplication.CreateNewView, but I can't seem to find a reference to that method within the WinJS or Windows namespaces in my Javascript. According to code-hints when I am writing my Javascript, I am able to see that there is a Windows.ApplicationModel.Core namespace, but the only class that appears in it is AppListEntry. No CoreApplication or any of the other classes that the documentation suggests should be there.

I've been digging around trying to find out if this is possible. I haven't been able to find any resources that specifically say you can't perform this action in a WinJS app, but I haven't found any examples that show how to do this either.

I downloaded the Universal Windows App Samples, and they do have a MultipleViews project there, but it doesn't include a JS build.

Does anyone know if it is possible to open a new window from within a WinJS app?

Upvotes: 1

Views: 493

Answers (1)

Dave Voyles
Dave Voyles

Reputation: 4605

What happens when you do:

window.open("http://www.w3schools.com");

Or set target as "_blank" as you would do for an HTML window?

<a href="http://www.w3schools.com" target="_blank">Visit W3Schools</a> 

There is tool written for the Intel XDK (A Cordova product), which can work around some of the limitations of JS running on Windows. Here is a link: https://github.com/xmnboy/xdk-win8x-compat.js . It may resolve some of these issues.

When I was writing Win8 JS apps, I know that I could wrap a function in:

MSApp.execUnsafeLocalFunction(unsafeFunction);

(documentation), which would allow me to inject JS to the DOM. You may be able to write a function that creates a new window with that.

Upvotes: 0

Related Questions