Html程序  |  46行  |  1.35 KB

<html>
  <head><title>window.close test</title>
    <script type="text/javascript" src="chrome_frame_tester_helpers.js">
    </script>
    <script type="text/javascript">
      function OnNavigationFailed() {
        onFailure("WindowCloseTest", 1, "ChromeFrame Navigation failed");
      }

      function OnChromeFrameLoaded(url) {
        appendStatus("Loaded URL: " + url.data);
        var cf = window.document.ChromeFrame;
        if (cf.attachEvent) { // Special case for IE
          appendStatus("Attaching close event handler");
          cf.attachEvent("onclose", OnCloseWindow);
        }
      }

      function OnCloseWindow() {
        appendStatus("Received window close event.");
        return onSuccess("WindowCloseTest", 1);
      }

    </script>
  </head>
  <body>
      <div id="statusPanel" style="border: 1px solid red; width: 100%">
      Test running....
      </div>

      <span id="ChromeFrameSpan"></span>
      <script type="text/javascript">
insertControl(
    "ChromeFrameSpan",
    { "src": "window_close_frame.html",
      "eventHandlers": {
        "onload": "return OnChromeFrameLoaded(arguments[0]);",
        "onloaderror": "return OnNavigationFailed(arguments[0]);",
        "onclose": "return OnCloseWindow();"
      }
    });
      </script>
      <p>Tests window.close notification from ChromeFrame to its container</p>
  </body>
</html>