【问题标题】:iframe visual studio html5 windows 8 appiframe 视觉工作室 html5 windows 8 应用程序
【发布时间】:2013-11-16 17:25:23
【问题描述】:

我正在创建我的第一个 Metro 风格的 Windows 8 应用程序。 我正在尝试使用 runescape 的 iframe 来做到这一点。

这是我的代码:

    <!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>

这是我得到的错误:

APPHOST9625:Kan niet navigeren naar:'http://www.runescape.com/game'。 Een iframe heeft geprobeerd om naar een URI te navigeren die niet is de ApplicationContentUriRules voor deze 应用程序中的 opgenomen。格布鲁克 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。 (沃格在 Visual Studio deze URI toe aan het tabblad Content URIs van de 清单设计器。)

(用谷歌翻译成英文是:

APPHOST9625:无法导航到:http://www.runescape.com/game。 iframe 已尝试导航,但此应用的 ApplicationContentUriRules 中未包含该导航。到 URI 相反,使用 x-ms-webview 元素来查看 URI 是否将 URI 添加到包清单的 ApplicationContentUriRules 部分,以便 iframe 去那里导航。 (在 Visual Studio 中将此 URI 写入清单设计器 URI 的“内容”选项卡。)

谷歌没有帮助,所以我在这里问它。

【问题讨论】:

标签: javascript html iframe visual-studio-2013


【解决方案1】:

您需要打开 apppackage.manifest 文件并转到 Content URIs 选项卡,包括您尝试从 iframe 启动的 url。

【讨论】:

  • “不,此设置不会影响 WebView 控件中包含的 iframe 元素”。这在上面的行中进行了描述。
【解决方案2】:

迁移到 Windows 8.1 时,在大多数情况下,您应该使用 x-ms-webview 控件代替 iframe。它通常就像在您的标记中替换为一样简单。但是,如果您在 Win8 中与 iframe 进行 postMessage 通信,则需要将该代码转换为使用 webview 的 invokeScriptAsync(调用 webview 中的函数)并使用 window.external.notify 将事件返回给应用程序。

【讨论】:

    【解决方案3】:

    对于 Windows 8.1 应用,您不能再将 iframe 用于不安全的 http URI。您将在问题中收到错误消息,提示您可以将 URI 添加到 ApplicationContentUriRules,但它只允许您将 https URI 添加到规则中。

    因此,如果您想从您的应用中提供不安全的内容,则必须使用专有的 &lt;x-ms-webview&gt; 标签而不是 &lt;iframe&gt;。 (例如&lt;x-ms-webview src="http://www.google.com"&gt;

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-01
      • 1970-01-01
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多