快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

jquery获取父页面,jquery获取父页面的值

jquery嵌套网页获取最外层父页面

最外层父页面:

专注于为中小企业提供成都做网站、成都网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业江津免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

function popup(childFrame,callback){

// do something

childFrame[callback].call(childFrame,returnValue);

}

子页面:

elem.onclick = function(){

window.top.popup(window.self,"doInChildFrame");

}

function doInChildFrame(returnValuse){

// do something with returnValue

}

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

jquery获取父窗口元素的方法

(1)$("#id",window.opener.document).val(赋值);

或者$("#id",window.opener.document).html(赋值)

(2)上述(1)中的id为父窗口元素的id,获得后可以给赋值用val方法或者html方法

(3)原生js可以这样写:

window.opener.document.getElementById("id").value=赋值或者

window.opener.document.getElementById('cname').innerHTML=赋值

Jquery如何获取父级页面

子页面元素需要获取父页面的元素做如下操作:

$("#父页面元素id" , parent.document)

js/jquery如何获取父窗口的元素?

取父窗口的元素方法:

$(selector, window.parent.document);

那么你取父窗口的父窗口的元素就可以用:

$(selector, window.parent.parent.document);

类似的,取其它窗口的方法大同小异,

$(selector, window.top.document);

$(selector, window.opener.document);

$(selector, window.top.frames[0].document);

js:

父窗口:

1、input type="text" name="currentProjectIDForDetail" id="currentProjectIDForDetail"

disabled

2、input type="button"

onclick="window.open('showDetails.html','','toolsbar=no,menubar=no,resizable=yes,scrollb

ars=yes')" value="查看已有明细" id="showDetail" /

子窗口:

curproject = window.opener.document.getElementById("currentProjectIDForDetail").value;

jQuery:

父窗口:

input type="text" name="aa" id="aa" /

input type="button"

onclick="window.open('son.html','','toolsbar=no,menubar=no,resizable=yes,scrollbars=yes')

" value="send" /

子窗口:

script

$(function () {

temp=$("#aa",window.opener.document).val();

$("#bb").html(temp);

})

/script

/head

body

div id="bb"/div

子页面jQuery获取父页面jQuery的一个全局变量

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

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

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

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

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

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

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

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

parent.xxx;

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

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

父窗体提交两个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 部分:

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

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

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

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


分享名称:jquery获取父页面,jquery获取父页面的值
分享路径:http://6mz.cn/article/dssipoi.html

其他资讯