0

我在两个不同的 Web 应用程序中有以下两个 html 文件。WebApp1(somedomain.com)PassValueIFrame.htmlWebApp2inputForm.htmlHere WebApp1 is secured and requires authentication. 在PassValueIFrame.html 我有一个 iframe 引用inputForm.html。另外,我有一个隐藏字段,PassValueIFrame.html我试图在其中检索它的值,inputForm.html但没有得到它的值,它警告为“ Permission denied to access property 'document'”。我在这里做错了吗?请帮我。由于WenbApp1是安全的,我们不能访问PassValueIFrame.html吗?如果我们无法访问,那么有什么方法可以访问受保护的页面内容?

PassValueIFrame.html

<html>
  <head>
  <title>IFrame Example</title>
  </head>
<body>
<input id="myInput" type="hidden" class="Language" value="English">
<iframe name="iframe" id="iframe_id" src="http://somedomain.com/inputForm.html" height="150" >
</iframe>
</body>
</html>

inputForm.html

<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script language="javascript">
  $(document).ready(function() {
    alert($("#myInput", window.parent.document).val());
  });

  </script>
   <title>IFrame Child Example</title>
</head>
<body>
<h1> Iframeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee </h1>
</body>

谢谢!

4

1 回答 1

1

您似乎违反了同源政策限制。如果父级和 iframe 都托管在同一个域上,则您无法访问 iframe 内容。所以基本上,如果你想让它工作,你将不得不PassValueIFrame.htmlhttp://somedomain.com.

于 2013-08-05T07:25:57.887 回答