我有这个HTML代码:
<html>
  <head>
    <script type="text/javascript">
      function GetDoc(x)
      {
        return x.document ||
          x.contentDocument ||
          x.contentWindow.document;
      }
      function DoStuff()
      {
        var fr = document.all["myframe"];
        while(fr.ariaBusy) { }
        var doc = GetDoc(fr);
        if (doc == document)
          alert("Bad");
        else 
          alert("Good");
      }
    </script>
  </head>
  <body>
    <iframe id="myframe" src="http://example.com" width="100%" height="100%" onload="DoStuff()"></iframe>
  </body>
</html>
问题是我收到消息“错误”。这意味着iframe的文档未正确获取,而GetDoc函数实际返回的是父文档。
如果您告诉我在哪里犯错,我将不胜感激。(我想将文档托管在IFrame中。)
谢谢。