简体   繁体   中英

Do Windows 8 apps run on standards-compliant JavaScript, HTML5, and CSS3?

Like most .NET developers I was watching the keynote for the Build Event in Anaheim, Cali and had a questions about the new support for building applications for Windows 8 using JavaScript, HTML5 and CSS3.

They showed quite a few examples and even said the new Windows 8 marketplace was written using these technologies. The only thing that kind of has me guessing is when they put JavaScript in the same category of C#, in the sense that you could program your windows apps (have access to .NET directly) using JavaScript.

Obviously being a web developer this was pretty awesome news considering some of the applications I've built using JavaScript, HTML5 and CSS3.

The question I have is whether or not the applications we build for Windows 8 are truly web compliant? Can we build apps for Windows 8 and turn around and launch them on the web? Can web applications that are currently online access some of the features they demoed?

Like I said this would be an awesome advancement. Not to put down Silverlight, which I have written quite a few applications for, and the way it works in blend rocks. And the thought of replacing JavaScript with some of my apps that are written in C# is not even an option.

Is this just to get "web" based developers to develop for Windows or is this a cross platform solution for building applications?

Slight clarification, the Javascript/HTML5/CSS3 windows programs run on a new layer called WinRT (Windows Runtime), not .Net. All of the new Windows Metro style apps will be built on top of this layer rather than the older .Net. If your app utilizes the WinRT features, obviously you would need Windows to run the app. It is your choice if you want to integrate those features. (Obviously it depends on what you are trying to do with your app) I believe you can build an all standards compliant app and have it run on the system just fine - you just won't be using any MS specific features. In that sense, it would be like a webpage that you launch as an app.

Other notes:

  • MSIE currently uses some -ms specific prefixes until those features are accepted by W3C and given official cross browser names. Not unlike -webkit-border-radius , -moz-border-radius and border-radius .

  • The HTML5 uses some features such as grids that are not yet implemented in most browsers.

  • Microsoft includes a lot of Javascript libraries to make it easy to build apps. Many of these are jQuery based. Some are Windows specific. Not sure what the licensing is to use them elsewhere. I assume the jQuery is allowed to be portable whereas the Windows ones, wouldn't make sense to use outside of WinRT.

@Matt

To clarify the "converse", standard web app written in HTML5 running as a Metro application:

Assuming your application isn't doing "Bad Things" then yes. The Metro app environment is restricted by default. In order to access non-local resources (eg a website) from within the application in HTML5/JS, you must create what is known as a "Web Context".

The Web Context allows an application access to the internet and unsafe resources while preventing that same context from accessing privileged resources, like the Windows Runtime APIs.

This ultimately means that if you need to host a Bing Maps widget and want to get GPS information from the system, you would need the following:

  1. an iframe inside the page (which is Local Context by default) hosting a Web Context that contains your Bing Maps widget
  2. use window.postMessage to send data between the Local Context and the Web Context (contained in the iframe)
  3. Call the Windows Runtime API for accessing the GPS location of the device from the Local Context mentioned above

This application model affords you the security that no website opened inside the JS application will have rogue JS executing Windows Runtime APIs to scrape your data. This is probably the biggest area that you will have to re-architect in an existing web application to get it running as you must push data between contexts if it comes from an unsafe resource.

Short answer is no -- apps built using the WinRT stack won't be able to run in a "normal" browser. I'm not sure about the converse though -- if a standard web application written with HTML5 can be run as a Metro app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM