admin管理员组文章数量:1336289
I want to include a web hosted piece of javascript to act as a widget in my metro application. The goal would be to be able to maintain the state of the widget outside of the metro app so that a change to the widget code wouldn't require a repackaging and publishing to the app store.
e.g. (in my html file in the metro app)
<script type="text/javascript" src="/widget.js">
I want to include a web hosted piece of javascript to act as a widget in my metro application. The goal would be to be able to maintain the state of the widget outside of the metro app so that a change to the widget code wouldn't require a repackaging and publishing to the app store.
e.g. (in my html file in the metro app)
<script type="text/javascript" src="https://link.to.website/widget.js">
Share
asked Mar 4, 2012 at 5:02
AbadabaAbadaba
1,4667 gold badges20 silver badges30 bronze badges
1
- 2 If you do this, make sure it works without internet access too, or it will probably get rejected from the store. – parkovski Commented Mar 4, 2012 at 20:08
2 Answers
Reset to default 9It's important to understand the differences between the local and web context. Particular restrictions are documented here: http://msdn.microsoft./en-us/library/windows/apps/hh465373.aspx -- what is worth noting is that you can only include external script files from pages running in the web context.
Also, your app always has to have a top level page that is in your package. This page must be in the local context and loaded via the ms-appx scheme. This outer page may choose to iframe pages loaded in the web context (via ms-appx-web for in-package files or via http/https for pages hosted on the web.)
What you should keep in mind is that even though you can load external script into a web context page, that script cannot access the Windows Runtime APIs. If you want your external script to be able to call WinRT, you can create a munication channel using the HTML5 Web Messaging APIs.
If the metro apps lets you connect to the net (if the app is not limited to local-only or similar) that should be possible.
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 have to declare that nowadays.
本文标签: windows 8Can web hosted javascript files be included in metro appsStack Overflow
版权声明:本文标题:windows 8 - Can web hosted javascript files be included in metro apps? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742406429a2468914.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论