Freigeben über


Universal apps - create JavaScript apps for Windows and Windows Phone

At Microsoft's BUILD conference this week, platform and tool support
has been made available for developers to build "universal apps".
Developers can now create a single solution that targets Windows 8.1 and
Windows Phone 8.1 using shared code. You can do this using XAML with C#/VB/C++,
or by using HTML and JavaScript.

Being a JavaScript enthusiast, and also assigned to the language, I'm most excited
about the fact that you can now use HTML and JavaScript for Windows Phone.
Cool. Being able to do it in a single VS solution using shared code is gravy.

I ported my JSON Web reader app to a universal app template
in Visual Studio 2013 Update 2 (required). This solution targets both Window 8.1
and Windows Phone 8.1. You can check out that app here:

To get Visual Studio 2013 Update 2, which includes the Phone Emulator, and to get general info
about universal apps, go here:

To use the Phone Emulator, you need a machine with second level address translation (SLAT). For more info, go here:

For info about the templates, go here:

For info on porting a Windows Store app to the phone
(JavaScript emphasis), go here:

Besides the JSON Web Reader, I've worked on porting various other test samples to Phone. In most cases, I've been pleasantly surprised how easy it is. There are a number of controls that aren't cross-platform, which require more work. But generally, most of the extra work is around coding for different display sizes. Typically, you will use different HTML files for each platform (Phone and Windows have a separate project and app package within the shared solution), but you can use the same JavaScript code. In JavaScript code, you can test whether a feature is available before using it, or call WinJS.Utilities.isPhone to check your platform target. See the above links for more details.