简体   繁体   English

如何在Microsoft Appstudio中向HTML添加脚本

[英]how to add script to html in Microsoft Appstudio

I am trying to add a script inside html in Microsoft Appstudio 我正在尝试在Microsoft Appstudio的 html内添加脚本

But when i refresh and check it is removing the <script> 但是当我刷新并检查它正在删除<script>

I checked in their how to page but it didnt help 我检查了他们如何翻页,但没有帮助

在此处输入图片说明

You can do it, kinda, but its a hack.... 您可以做到,但它是一个hack ....

First you can't do functions like alert() in the WebView control that app studio uses. 首先,您无法在App Studio使用的WebView控件中执行诸如alert()之类的功能。 Alert is considers a 'secondary window'. 警报被视为“辅助窗口”。 Anything that uses a secondary window you cannot use. 任何使用辅助窗口的内容都无法使用。 If you need to use 'alert()' I can develop you a separate hack for that. 如果您需要使用“ alert()”,那么我可以为您开发一个单独的hack。

Also beware WebView always uses Internet Explorer 11 in document mode. 另外请注意,WebView始终以文档模式使用Internet Explorer 11。 It does not support any ActiveX controls or plugins like Microsoft Silverlight or Portable Document Format (PDF) files. 它不支持任何ActiveX控件或插件,例如Microsoft Silverlight或可移植文档格式(PDF)文件。 The WebView does not support some HTML5 features including AppCache, IndexedDB, programmatic access to the Clipboard, and geolocation. WebView不支持某些HTML5功能,包括AppCache,IndexedDB,对剪贴板的编程访问以及地理位置。

On to the hack. 进行破解。

  • Add a html widget to your app studio app online. 在线将html小部件添加到您的App Studio应用。 I just use stub 我只是用存根
  • Generate source code from your appstudio app 从您的appstudio应用生成源代码
  • Extract out the source code and open in vs2015 Navigate to /Assets/Data/Html.htm (you may have multiples) 提取源代码并在vs2015中打开导航到/Assets/Data/Html.htm(您可能有多个)
  • Add your scripted and styled source to html.html 将脚本化和样式化的源添加到html.html

Test out your app, but you should be ready to go at this point 测试您的应用程序,但此时您应该已经准备就绪

Note this is a mod you will have to do EVERY TIME you modify your app in AppStudio. 请注意,这是您每次在AppStudio中修改应用程序时都必须执行的mod。 I just keep .htm files outside of my project and drag them in after I generate source code. 我只是将.htm文件保留在项目之外,并在生成源代码后将它们拖入其中。

If you want to see this process I pushed a video documenting it step by step to https://channel9.msdn.com/Blogs/raw-tech/AppStudio-How-to-Add-script-to-the-HTML-Widget . 如果您想看这个过程,我将视频逐步记录到https://channel9.msdn.com/Blogs/raw-tech/AppStudio-How-to-Add-script-to-the-HTML-Widget

If you need more info on the prices to publish AppStudio to Win10 using the source code option, check out https://channel9.msdn.com/Blogs/raw-tech/AppStudio-Publish-to-Windows-10-Store-from-Source-Code . 如果您需要更多有关使用源代码选项将AppStudio发布到Win10的价格的信息,请查看https://channel9.msdn.com/Blogs/raw-tech/AppStudio-Publish-to-Windows-10-Store-from -源代码

Not the best route, but definitely do-able. 不是最佳路线,但绝对可行。 Hope this helps. 希望这可以帮助。 Healy in Tampa 坦帕的希利

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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