Can javascript web files be included in metro apps?

I want to enable the javascript web part to act as a widget in my metro application. The goal would be to maintain the state of the widget outside the metro application so that changing the widget code does not require repackaging and publication in the application store.

eg. (in my html file in the metro application)

<script type="text/javascript" src="https://link.to.website/widget.js"> 
+6
source share
2 answers

It is important to understand the differences between your local and web context. Specific limitations are described here: http://msdn.microsoft.com/en-us/library/windows/apps/hh465373.aspx - it is worth noting that you can only include external script files from pages running in a web context.

In addition, your application should always have a top-level page that is in your package. This page should be in the local context and loaded via the ms-appx schema. This external page can select iframe pages loaded into the web context (via ms-appx-web for in-package files or via http / https for pages hosted on the Internet.)

What you should keep in mind is that even if you can upload an external script to the context web page, the script will not be able to access the Windows Runtime APIs. If you want your external script to be able to call WinRT, you can create a communication channel using the HTML5 Web Messaging API .

+9
source

If metro applications allow you to connect to the network (if the application is not limited to local or similar), perhaps < .

also:

 <script src="https://link.to.website/widget.js"></script> 

not

 <script type="text/javascript" src="https://link.to.website/widget.js"> 

Since JavaScript is the standard type for script, you do not need to declare it now.

+1
source

Source: https://habr.com/ru/post/909918/


All Articles