我见过这个SO发布有关使用iframe和做postMessage的帖子:Metro App and iFrame cookie。我试图在Win8 Release Preview中使用HTML/JS Metro应用程序做一些非常类似的事情,但似乎不太可能在该解决方案中复制行为。Metro应用程序中的远程iframe问题
我具有存储在一个远程位置作为一个简单的框架:
<!DOCTYPE html>
<html>
<body>
<script>
window.onmessage = function(e) {
alert("Hello world");
debugger;
};
</script>
</body>
</html>
以我default.html中我有一个包含的IFRAME如下一个div:
<div id="container">
<iframe id="frame" src="https://dl.dropbox.com/u/75275447/win8Frame.html"></iframe>
</div>
我具有任意按钮在#frame上执行postMessage,并在正常的Html站点中触发远程框架onmessage,但是我可以查看VS中的错误列表并参见:
APPHOST9613: The app couldn’t navigate to https://dl.dropbox.com/u/75275447/win8Frame.html because of this error: RESOURCE_NOT_FOUND.
我试图寻找到这可能让我实现这一目标并启用任何明显的:
- 家庭或工作网络
- 上网(客户端&服务器)
- 上网(客户端)
无济于事...我也尝试了一个框架(本地应用程序)加载到网络contenxt(通过ms-wwa-web://),其中包含一个宿主远程iframe的div并链接消息转发一个postMessage的远程iframe中,但我又看到另一个错误:
APPHOST9624: The app can’t use script to load the ms-wwa-web://frame.html/ url because the url launches another app. Only direct user interaction can launch another app.
我开始认为这是一个不可能完成的任务。