简体   繁体   中英

How to run a script from the Web in a Windows 8 app?

My organization already developed iOS and Android apps, and is starting to develop an app for Windows 8. In case it matters, the app is using Phonegap aka Cordova. On the existing apps, the user downloads a very "slim" app from the store, containing a minimal HTML page. The user logs into a server, and then script tags are dynamically added pointing to locations on that server. Similar to web apps, scripts are downloaded to the client and then executed.

Windows 8's new security model blocks this behavior. Since the app runs in the local context and the script is on the web, I get the error "An app can't load remote web content in the local context."

Is there a way to get around this restriction?

I'm open to "creative" suggestions and hacks, up to a point. I've already tried a few things, such as fetching a script with plain XHR calls and then injecting the response to a pre-defined script tag. Windows blocked this and all other attempts.

I also considered rendering everything in an iframe with a "ms-appx-web:" scheme (learned about this scheme here , "Schemas and contexts" section). This might allow me to load remote scripts, but would prevent code from accessing APIs of the locally-running JavaScript code -- Cordova and Windows Runtime. This access is necessary for my app. If there's a way to access Cordova and Windows Runtime from the web context, that might be useful too.

I very much doubt it.

The whole point of the MS Windows Store certification model is that they can test your code for malware/ crashes. If you can change the code on the fly, you could ship a perfectly harmless app, have it certified by MS, and then change it to something dreadful after the user installs it.

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