javascript - 如何将数据从 iframe 传递到父窗口?

标签 javascript

我使用了 3 个 .asp 页面

第1页:Parent.asp 第 2 页:Subparent.asp 第 3 页:Child.asp

在 child.asp 中使用 javascript。我想将数据从子窗口(iframe)传递到父窗口

<title>parent.asp</title>
<html>
<body>
<iframe name="I1" frameborder="0" scrolling="no"  src="Subparent.asp" width="100" 
height="100">
        <title>subparent.asp</title>
        <html>
        <body>
<div id ="parentdata"></div>
        <iframe name="I1" frameborder="0" scrolling="no"  src="Subparent.asp" width="100" height="100">
              <title>subparent.asp</title>
              <html>
              <body>
               <iframe name="I1" frameborder="0" scrolling="no"  src="Child.asp" width="100" height="100">
                       <title>subparent.asp</title>
                       <html>
                       <body>
<script language="JavaScript">
{
parent.document.getElementById("parentdata").innerHTML="GET DATA, WORKING"
}
</script>
                       </body>
                       </html>
              </iframe>
              </body>
              </html>        
        </iframe>
        </body>
        </html>
</iframe>
</body>
</html>

在“Child.asp”中,我使用 javascipt。我想将数据传递给“parent.asp”的“”

有可能吗,请帮帮我

希望大家多多支持

最佳答案

也许 ajax 是满足您需要的最佳方式。 但如果您仍然喜欢 iframe,您可以尝试:

父级.asp:

function myFunction(pram1, param2)
{
    alert('worked! - param1: '+param1.toString()+' param2: '+param2.toString());
}

子类.asp

top.myFunction(1,2);

关于javascript - 如何将数据从 iframe 传递到父窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2243575/

相关文章:

c# - 如何调用 C# 类的 COM Interop,使用 javascript 的方法

javascript - JS正则表达式重复唯一字符

javascript - 获取相关的 Jquery 子菜单以在新页面加载时保持打开状态?

javascript - _gaq.push 没有出现在 Google Analytics 中

javascript - 如果值 >= 15 语句 TypeScript

javascript - 如何在jquery中实现mouseleave

javascript - 如何更改 TimeCircles 的高度和宽度?

javascript - 直接在 JS 中动态改变 transition 还是使用 css classes 对性能更好?

javascript - 我appendChild(表单输入)那么我如何从最后一个第一个删除新输入?

javascript - 在 php 中的 if 语句中未读取变量