【转载】用jQuery在IFRAME里取得父窗口的某个元素的值

只好用DOM方法与jquery方法结合的方式实现了

1.在父窗口中操作 选中IFRAME中的所有单选钮
/

$(window.frames["iframe1"].document).find("input[ at type='radio']") dot attr("checked","true");

2.在IFRAME中操作 选中父窗口中的所有单选钮
/

$(window.parent.document).find("input[ at type='radio']") dot attr("checked","true");
/

iframe框架的:<iframe src="test.html" id="iframe1" width="700" height="300" frameborder="0" scrolling="auto"></iframe>

IE7中测试通过

在父页面访问Iframe子窗体的txtAddress控件
/

window.frames["ifrMapCompanyDetails"].document.all("txtAddress").value = '地址' ;
/

 

在Iframe子窗体1访问父页面的TextBox1控件 , 子窗体1把值赋给子窗体2的某个控件
/

string strValue = "从子窗体传递给父页面的值" ;

下面是在Page_Load事件里面调用的,当然可以写在javascript脚本里面

this.Response.Write("<script>parent.document.all('TextBox1').value = '" + strValue + "';</script>");

this.Response.Write("<script>if( parent.document.all('TextBox2').value = '0')parent.document.all('TextBox1').value = '44';</script>");
/

子窗体访问父窗体中的全局变量:

parent.xxx;
/

 

在Iframe子窗体1访问子窗体2的txtAddress控件 子窗体1把值赋给子窗体2的某个控件
/

window.parent.frames["ifrMapCompanyDetails"].document.all("txtAddress").value = '地址' ;

 

/*本文字内容,不影响代码正常运行:星网科技HTTP://5UU8.COM/blog/版权所有,本站首发,转载请注明*/
父窗体提交两个Iframe子窗体

window.frames["ifrMapCompanyDetails"].Form1.submit();
/

window.frames["ifrMapProductInfoDetails"].Form1.submit();

 

Iframe子窗体 调用父页面的javascript事件

window.parent.XXX()

 

//父页面调用当前页面中IFRAME子页面中的脚本childEvent
/

function invokechildEvent()

{ var frm = document.frames["ifrChild1"].childEvent(); }
/

或者调用当前页面中第一个IFRAME中的脚本childEvent
/

{ var frm = document.frames[0]; frm.childEvent(); }
/

 

//子页面调用父窗体的某个按钮的按钮事件

window.parent.Form1.btnParent.click()
/

 

父页面调用子窗体的某个按钮的按钮事件
/

window.frames['ifrChild1'].document.all.item("btnChild3").click();

 

//jquery 部分:
/*本文字内容,不影响代码正常运行:星网科技HTTP://5UU8.COM/blog/版权所有,本站首发,转载请注明*/
1.在父窗口中操作 选中IFRAME中的所有单选钮
/*

$(window.frames["iframe1"].document).find("input[ at type='radio']") dot attr("checked","true");
/

 

/*本文字内容,不影响代码正常运行:星网科技HTTP://5UU8.COM/blog/版权所有,本站首发,转载请注明*/
2.在IFRAME中操作 选中父窗口中的所有单选钮
/*

$(window.parent.document).find("input[ at type='radio']") dot attr("checked","true");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北方的刀郎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值