如何通过JQuery实现子窗口 *** 作父窗口

如何通过JQuery实现子窗口 *** 作父窗口,第1张

在web开发中,经常会用到iframe,难免会碰到需要在父窗口中使用iframe中的元素、或者在iframe框架中使用父窗口的元素

在父窗口中获取iframe中的元素

格式:$("#iframe的ID")contents()find("#iframe中的控件ID")click();

实例:$("#ifm")contents()find("#btnOk")click();

在iframe中获取父窗口的元素

格式:$('#父窗口中的元素ID', parentdocument)click();

实例:$('#btnOk', parentdocument)click();

您可能感兴趣的文章:

JQUERY 获取IFrame中对象及获取其父窗口中对象示例

Jquery中获取iframe的代码

jquery获取iframe中的dom对象(两种方法)

最外层父页面

function popup(childFrame,callback){

    // do something

    childFrame[callback]call(childFrame,returnValue);

}

子页面:

elemonclick = function(){

    windowtoppopup(windowself,"doInChildFrame");

}

function doInChildFrame(returnValuse){

    // do something with returnValue

}

这样,在子页面中的elem元素被点击之后,就会触发最外层父页面的popup函数,并且把子页中的window对象传给父页面,当父页面执行完 *** 作之后,就会执行子页面的"callback"函数,还可以传入参数。

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

windowframes["ifrMapCompanyDetails"]documentall("txtAddress")value = '地址' ;

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

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

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

thisResponseWrite("<script>parentdocumentall('TextBox1')value = '" + strValue + "';</script>");

thisResponseWrite("<script>if( parentdocumentall('TextBox2')value = '0')parentdocumentall('TextBox1')value = '44';</script>");

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

parentxxx;

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

windowparentframes["ifrMapCompanyDetails"]documentall("txtAddress")value = '地址' ;

父窗体提交两个Iframe子窗体

windowframes["ifrMapCompanyDetails"]Form1submit();

windowframes["ifrMapProductInfoDetails"]Form1submit();

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

windowparentXXX()

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

function invokechildEvent()

{ var frm = documentframes["ifrChild1"]childEvent(); }

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

{ var frm = documentframes[0]; frmchildEvent(); }

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

windowparentForm1btnParentclick()

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

windowframes['ifrChild1']documentallitem("btnChild3")click();

//jquery 部分:

1在父窗口中 *** 作 选中IFRAME中的所有单选钮

$(windowframes["iframe1"]document)find("input[@type='radio']")attr("checked","true");

2在IFRAME中 *** 作 选中父窗口中的所有单选钮

$(windowparentdocument)find("input[@type='radio']")attr("checked","true");

子级调用父级方法:假设有父级的方法add() ,调用方式 selfparentadd();

子级获取父级元素 $(windowparentdocument)find("#idd")html()

B页面整体刷新,楼上的回答应该可以

以上就是关于如何通过JQuery实现子窗口 *** 作父窗口全部的内容,包括:如何通过JQuery实现子窗口 *** 作父窗口、jquery嵌套网页获取最外层父页面、子页面jQuery获取父页面jQuery的一个全局变量等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/10160296.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存