简体   繁体   English

iframe visual studio html5 windows 8 app

[英]iframe visual studio html5 windows 8 app

I'm creating my first windows 8 app in metro style. 我正在创建我的第一个地铁风格的Windows 8应用程序。 I'm trying to do this with a iframe for runescape. 我正在尝试使用iframe for runescape。

This is my code : 这是我的代码:

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Runescape_Metro_Client</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.2.0/js/base.js"></script>

    <!-- Runescape_Metro_Client references -->
    <link href="/css/default.css" rel="stylesheet" />
    <script src="/js/default.js"></script>
</head>
<body>
    <iframe sandbox="allow-scripts" id="Iframe" src="http://www.runescape.com/game" style="width:100%; height:100%"></iframe>
</body>
</html>

and this is the error i get : 这是我得到的错误:

APPHOST9625: Kan niet navigeren naar: ' http://www.runescape.com/game '. APPHOST9625:Kan niet navigeren naar:' http ://www.runescape.com/game'。 Een iframe heeft geprobeerd om naar een URI te navigeren die niet is opgenomen in de ApplicationContentUriRules voor deze app. Een iframe heeft geprobeerd om naar een URI te navigeren die niet是de ApplicationContentUriRules voor deze app中的opgenomen。 Gebruik in plaats daarvan een x-ms-webview-element om de URI te bekijken of voeg de URI toe aan de ApplicationContentUriRules-sectie van het pakketmanifest, zodat het iframe daarnaartoe kan navigeren. gebruik in plaats daarvan een x-ms-webview-element om de URI te bekijken of voeg de URI toe aan de ApplicationContentUriRules-sectie van het pakketmanifest,zodat het iframe daarnaartoe kan navigeren。 (Voeg in Visual Studio deze URI toe aan het tabblad Content URIs van de Manifest Designer.) (Voeg in Visual Studio deze URI toe aan het tabblad Content URIs van de Manifest Designer。)

(translated to english with google translate it is: (用谷歌翻译成英文翻译是:

APPHOST9625: Can not navigate to: http://www.runescape.com/game . APPHOST9625:无法导航至: http ://www.runescape.com/game。 An iframe has tried to navigate that is not included in the ApplicationContentUriRules for this app. iframe尝试导航,但不包含在此应用的ApplicationContentUriRules中。 To a URI Instead, use an x-ms-webview element to see if the URI add the URI to the ApplicationContentUriRules section of the package manifest, so the iframe go there to navigate. 到URI相反,使用x-ms-webview元素来查看URI是否将URI添加到包清单的ApplicationContentUriRules部分,因此iframe将在那里进行导航。 (Write in Visual Studio this URI to the Content tab of the Manifest Designer URIs.) (在Visual Studio中将此URI写入Manifest Designer URI的Content选项卡。)

Google didnt help so thats why i am asking it here. 谷歌没有帮助,所以我在这里问它。

For Windows 8.1 apps, you can no longer use an iframe for non-secure http URIs. 对于Windows 8.1应用程序,您不能再将iframe用于非安全http URI。 You will get the error message in the question which suggests that you can just add your URI to ApplicationContentUriRules, but it will only allow you to add https URIs to the rules. 您将在问题中收到错误消息,建议您只需将URI添加到ApplicationContentUriRules,但它只允许您将https URI添加到规则中。

So you will have to use the proprietary <x-ms-webview> tag instead of <iframe> if you want to serve non-secure content from your app. 因此,如果要从应用程序提供非安全内容,则必须使用专有的<x-ms-webview>标记而不是<iframe> (eg <x-ms-webview src="http://www.google.com"> ) (例如<x-ms-webview src="http://www.google.com">

see http://www.kraigbrockschmidt.com/2014/01/13/frame-to-webview-part-one/ http://www.kraigbrockschmidt.com/2014/01/13/frame-to-webview-part-one/

When migrating to Windows 8.1, you should use the x-ms-webview control in place of an iframe in most cases. 迁移到Windows 8.1时,在大多数情况下,应使用x-ms-webview控件代替iframe。 It's generally as simple as replacing with in your markup. 它通常就像在标记中替换一样简单。 If you have postMessage communication with the iframe in Win8, however, you'll need to convert that code to use the webview's invokeScriptAsync (to call functions in the webview) and use window.external.notify to raise events back to the app. 但是,如果你在Win8中与iframe进行postMessage通信,则需要转换该代码以使用webview的invokeScriptAsync(以调用webview中的函数)并使用window.external.notify将事件提升回应用程序。

您需要打开apppackage.manifest文件并转到内容URI选项卡,包含您尝试从iframe启动的网址。

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

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