2

I've seen this SO posting about using iframe's and doing postMessage: Metro App and iFrame cookie. I'm trying to do something very similar in Win8 Release Preview with an HTML/JS Metro application, but it seems rather impossible to replicate the behavior in that solution.

I have a simple frame stored in a remote location as:

<!DOCTYPE html>
<html>
<body>
<script>
window.onmessage = function(e) {
    alert("Hello world");

    debugger;
};
</script>
</body>
</html>

In my default.html I have a div that contains the iframe as follows:

<div id="container">
    <iframe id="frame" src="https://dl.dropbox.com/u/75275447/win8Frame.html"></iframe>
</div>

I have an arbitrary button that executes a postMessage on #frame and would in a normal Html site trigger the remote frames onmessage, but instead I can look at the error list in VS and see:

APPHOST9613: The app couldn’t navigate to https://dl.dropbox.com/u/75275447/win8Frame.html because of this error: RESOURCE_NOT_FOUND.

I have tried looking into any manifest that might allow me to achieve this and enabled:

  • Home or Work Networking
  • Internet (Client & Server)
  • Internet (Client)

To no avail... I have also tried having a frame (local to the application) loaded into the web contenxt (via ms-wwa-web://) that contains a div that hosts the remote iframe and chain up onmessage to forward a postMessage to the remote iframe, but again I see another error:

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.

I'm beginning to think this is an impossible task.

Community
  • 1
  • 1
ShelbyZ
  • 1,494
  • 1
  • 14
  • 32

1 Answers1

0

The one piece of information I leave out as I considered it unrelated to this issue was an error found in the javascript console related to using Jquery that I found a solution in another SO post. Clearing up that issue now allows the app to load the remote iframe and I can press the button and see the message reach the remote iframe's javascript (in my case I see alert() being undefined, but I was just trying to prove that I could load and execute remote code).

I guess the moral of the story is clear up related javascript console errors...

Community
  • 1
  • 1
ShelbyZ
  • 1,494
  • 1
  • 14
  • 32