- 浏览: 321135 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (178)
- 程序人生 (9)
- 工作总结 (16)
- 我的功能实现 (8)
- J2SE总结 (8)
- 面试中用到的 (10)
- struts2 (15)
- jsp (4)
- js (21)
- 数据库 (7)
- 数据结构和算法 (3)
- jQuery (18)
- hibernate (3)
- web service (2)
- spring (1)
- mySQL (7)
- 服务器 (1)
- 缓存 (2)
- nginx (1)
- jquery.ui (1)
- 各类标签(Date转 string) (1)
- Raphael (3)
- maven (2)
- 大型分布式网站架构设计 (2)
- linux (1)
- java易犯错误 (1)
- 优化 (4)
最新评论
-
15381049808:
楼主写的很赞 我对中间的批量发送拿过来现在还好用 受益匪浅
java实现邮件抄送,密送,多个附件发送 -
猜猜猜:
你这不是选择了语言之后总是跳到同一个页面吗?比如登录页面,选择 ...
struts2国际化——实例 -
itshu:
struts2国际化——实例 -
itshu:
[flash=200,200][url][img][list] ...
struts2国际化——实例 -
ZP0605:
com.asia.home.cn这个包名好熟悉
struts2拦截器管理日志
一、父窗口调用iframe子窗口方法
1、HTML语法:<iframe name="myFrame" src="child.html"></iframe>
2、父窗口调用子窗口:myFrame.window.functionName();
3、子窗品调用父窗口:parent.functionName();
简单地说,也就是在子窗口中调用的变量或函数前加个parent. 就行
4、父窗口页面源码:
1.< html >
2.< head >
3.< script type = "text/javascript" >
4.
5.function say() {
6. alert("parent.html------ > I'm at parent.html");
7. }
8.
9.function callChild()
10.{
11. //document.frames("myFrame").f1();
12. myFrame.window.say();
13.}
14.</ script >
15.</ head >
16.
17.< body >
18.< input type = button value = "调用child.html中的函数say()" onclick = "callChild()" >
19.< iframe name = "myFrame" src = "child.html" > </ iframe >
20.</ body >
21.</ html >
5、子窗口页面:
1.< html >
2.< head >
3.< script type = "text/javascript" >
4.
5.function say()
6.{
7. alert("child.html--- > I'm at child.html");
8.}
9.
10.function callParent() {
11. parent.say();
12. }
13.</ script >
14.</ head >
15.< body >
16.< input type = button value = "调用parent.html中的say()函数" onclick = "callParent()" >
17.</ body >
18.</ html >
二、iframe 父窗口和子窗口相互的调用方法
1、IE中使用方法:
父窗口调用子窗口:iframe_ID.iframe_document_object.object_attribute = attribute_value
例子:onClick="iframe_text.myH1.innerText='http://www.pint.com';"
子窗口调用父窗口:parent.parent_document_object.object_attribute = attribute_value
例子:onclick="parent.myH1.innerText='http://www.pint.com';"
2、Firefox中使用方法:
上面在IE下没有问题,但在firefox下不正常。在firefox下,应该是如下调用方法:
父窗口调用子窗口:window.frames["iframe_ID"].document.getElementById("iframe_document_object").object_attribute = attribute_value
例: window.frames["iframe_text"].document.getElementById("myH1").innerHTML= "http://hi.zfrong2000.cn ";
子窗口调用父窗口:parent.document.getElementById("parent_document_object").object_attribute = attribute_value
例: parent.document.getElementById("myH1").innerHTML = "http:// zfrong2000 .cn ";
3、完整的例子
test.htm
1.< HTML >
2. < HEAD >
3. < TITLE > Test Page </ TITLE >
4. < script src = "prototype-1.4.0.js" > </ script >
5. < script language = "javascript" >
6. function show()
7. {
8. window.frames["iframe_text"].document.getElementById("myH1") .innerHTML = "http://hi.wonsoft.cn" ;
9. }
10. </ script >
11. </ HEAD >
12. < BODY >
13. < iframe height = "350" width = "600" src = "iframe_test.htm" name = "iframe_text" > </ iframe >
14. < form action = "" method = "post" >
15. < input name = "haha" id = "haha" type = "text" maxlength = "30" value = "haha" />
16. < br />
17. < textarea cols = "50" rows = "5" id = "getAttributeMethod" > </ textarea >
18. < input type = "button" onClick = "show();" value = "提交" />
19. </ form >
20. < h1 id = "myH1" > d </ h1 >
21. </ BODY >
22.</ HTML >
frame_test.htm
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2.< html xmlns = "http://www.w3.org/1999/xhtml" >
3. < head >
4. < meta http-equiv = "Content-Type" content = "text/html; charset=gb2312" />
5. < title > 无标题文档 </ title >
6. </ head >
7. < script language = "javascript" >
8. function show()
9. {
10. parent.document.getElementById("myH1") .innerHTML = http:// zfrong2000 .cn ;
11. }
12. </ script >
13. < body >
14. < h1 id = "myH1" > ha </ h1 >
15. < form action = "" method = "post" >
16. < input name = "abc" id = "abc" type = "text" maxlength = "30" value = "abc" />
17. < br />
18. < textarea cols = "50" rows = "10" id = "text" > </ textarea >
19. < br />
20. < input type = "button" value = "提交" onclick = "show();" />
21. </ form >
22. </ body >
23.</ html >
test.htm里面firefox下访问iframe 必须用name,不能用id,所以要改为name="iframe_test" 。
1、HTML语法:<iframe name="myFrame" src="child.html"></iframe>
2、父窗口调用子窗口:myFrame.window.functionName();
3、子窗品调用父窗口:parent.functionName();
简单地说,也就是在子窗口中调用的变量或函数前加个parent. 就行
4、父窗口页面源码:
1.< html >
2.< head >
3.< script type = "text/javascript" >
4.
5.function say() {
6. alert("parent.html------ > I'm at parent.html");
7. }
8.
9.function callChild()
10.{
11. //document.frames("myFrame").f1();
12. myFrame.window.say();
13.}
14.</ script >
15.</ head >
16.
17.< body >
18.< input type = button value = "调用child.html中的函数say()" onclick = "callChild()" >
19.< iframe name = "myFrame" src = "child.html" > </ iframe >
20.</ body >
21.</ html >
5、子窗口页面:
1.< html >
2.< head >
3.< script type = "text/javascript" >
4.
5.function say()
6.{
7. alert("child.html--- > I'm at child.html");
8.}
9.
10.function callParent() {
11. parent.say();
12. }
13.</ script >
14.</ head >
15.< body >
16.< input type = button value = "调用parent.html中的say()函数" onclick = "callParent()" >
17.</ body >
18.</ html >
二、iframe 父窗口和子窗口相互的调用方法
1、IE中使用方法:
父窗口调用子窗口:iframe_ID.iframe_document_object.object_attribute = attribute_value
例子:onClick="iframe_text.myH1.innerText='http://www.pint.com';"
子窗口调用父窗口:parent.parent_document_object.object_attribute = attribute_value
例子:onclick="parent.myH1.innerText='http://www.pint.com';"
2、Firefox中使用方法:
上面在IE下没有问题,但在firefox下不正常。在firefox下,应该是如下调用方法:
父窗口调用子窗口:window.frames["iframe_ID"].document.getElementById("iframe_document_object").object_attribute = attribute_value
例: window.frames["iframe_text"].document.getElementById("myH1").innerHTML= "http://hi.zfrong2000.cn ";
子窗口调用父窗口:parent.document.getElementById("parent_document_object").object_attribute = attribute_value
例: parent.document.getElementById("myH1").innerHTML = "http:// zfrong2000 .cn ";
3、完整的例子
test.htm
1.< HTML >
2. < HEAD >
3. < TITLE > Test Page </ TITLE >
4. < script src = "prototype-1.4.0.js" > </ script >
5. < script language = "javascript" >
6. function show()
7. {
8. window.frames["iframe_text"].document.getElementById("myH1") .innerHTML = "http://hi.wonsoft.cn" ;
9. }
10. </ script >
11. </ HEAD >
12. < BODY >
13. < iframe height = "350" width = "600" src = "iframe_test.htm" name = "iframe_text" > </ iframe >
14. < form action = "" method = "post" >
15. < input name = "haha" id = "haha" type = "text" maxlength = "30" value = "haha" />
16. < br />
17. < textarea cols = "50" rows = "5" id = "getAttributeMethod" > </ textarea >
18. < input type = "button" onClick = "show();" value = "提交" />
19. </ form >
20. < h1 id = "myH1" > d </ h1 >
21. </ BODY >
22.</ HTML >
frame_test.htm
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2.< html xmlns = "http://www.w3.org/1999/xhtml" >
3. < head >
4. < meta http-equiv = "Content-Type" content = "text/html; charset=gb2312" />
5. < title > 无标题文档 </ title >
6. </ head >
7. < script language = "javascript" >
8. function show()
9. {
10. parent.document.getElementById("myH1") .innerHTML = http:// zfrong2000 .cn ;
11. }
12. </ script >
13. < body >
14. < h1 id = "myH1" > ha </ h1 >
15. < form action = "" method = "post" >
16. < input name = "abc" id = "abc" type = "text" maxlength = "30" value = "abc" />
17. < br />
18. < textarea cols = "50" rows = "10" id = "text" > </ textarea >
19. < br />
20. < input type = "button" value = "提交" onclick = "show();" />
21. </ form >
22. </ body >
23.</ html >
test.htm里面firefox下访问iframe 必须用name,不能用id,所以要改为name="iframe_test" 。
发表评论
-
利用jquery1.7的ajax提交form表单很简单
2013-03-12 17:51 1470之前用ajax提醒form表单,要引入一个jquery-for ... -
页内内容查找(类型于ctrl+f)2
2013-01-08 15:39 1184<html> <META HTTP-EQUI ... -
js查询前三个月的时间
2013-01-08 15:17 4883import java.util.Calendar; impo ... -
通过XMLHttpRequest 可以获取的网页的运行状态,从返回状态判断网站是否挂了
2012-11-27 16:42 943通过XMLHttpRequest 可以获取的网页的运行状态,从 ... -
iframe载入完成时的事件监听
2012-11-21 14:35 1104在iframe里嵌入另外一个 ... -
parseInt(08)或者parseInt(09)错误
2012-11-05 09:59 898对于parseInt("01")到par ... -
js打印,打印预览
2012-10-08 09:45 968JS打印预览 2009-04-16 14:10:53 标签:休 ... -
window.showModalDialog 传大数据(Ojbect对象)到另一个页面
2012-09-21 14:01 9921:onePage.jsp var obj = new ... -
js 处理反斜杆的字符串
2012-08-24 14:58 1147如果有var = "d:\用户数据\zhutongy ... -
javascript页面右下角弹出类似QQ或MSN的消息提示
2012-08-20 17:11 1667<HTML><HEAD> <TI ... -
拿到iframe中id的值
2012-08-20 09:16 3916</table> </td> ... -
根据IP确定城市
2012-08-17 13:16 1088<script src="http://int ... -
window.showModalDialog非常好用
2012-05-28 15:27 1013例: one.jsp var str = window.sh ... -
js日期总结
2011-12-23 10:15 8791:var thisday = new Date(); 年 ... -
jsp,js跳转方式
2011-07-12 18:30 1641按钮式: <INPUT name="p ... -
js实现 鼠标拖动背景图片
2011-07-12 18:28 1556<html> <head> < ... -
下拉菜单跳转页面
2011-07-12 18:23 1163<script language="j ... -
整数相加
2011-07-12 18:14 1018苹果:<INPUT onpropertychange=c ... -
js常用技术
2011-07-12 18:05 884事件源对象 捕获释放 event.srcElement. ... -
js验证表单
2011-07-12 17:57 8061. 长度限制 <script> functi ...
相关推荐
本Demo汇总是iframe父页面与iframe子页面如何相互调用方法、元素及值的几种常见方法(含JS、JQuery方法)
NULL 博文链接:https://terryang.iteye.com/blog/292913
JavaScript实现IFrame子窗口调用父窗口的全局变量
jquery、js调用iframe父窗口与子窗口元素的方法整理.docx
本节主要介绍了jquery、js调用iframe父窗口与子窗口元素的方法,需要的朋友可以参考下
主要介绍了Chrome下ifame父窗口调用子窗口的问题,需要的朋友可以参考下
easyUi弹出window窗口传值与调用父页面的方法,子页面给父页面赋值,详情链接:
NULL 博文链接:https://747017186.iteye.com/blog/2168620
但是,如果一个文档定义了一个或者多个框架(即:包含一个或者多个frame或者iframe标签),浏览器就会为原始文档创建一个window对象,再为每个iframe创建额外的window对象,这些额外的window对象是原始窗口的子窗口。...
使用iframe的时候,可能会涉及到父子窗口之间传值和方法的相互调用,之前一直有些迷糊,也没有着意去弄清楚,这两天要干活,没法子了只好把这都弄明白了。其实非常简单,就那么几个用法,几句代码而已。 子窗口中...
实例如下: //调用父类方法 window.parent.exportData($('#shownum').val(),$('#splitstr').val())...以上这篇layer.open关闭父窗口 以及调用父页面的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希
第一:父窗口打开子窗口是一个新增用户信息的iframe子页面,点击保存后,子窗口iframe则去调用父窗口的function closeAddWindow()方法,让父窗口去关闭新增页面; 第二:父窗口打开一个设置用户权限的iframe子窗口,...
子窗口刷新父窗口 self.window.opener.locaction.reload(); 刷新一open()方法打开的窗口 window.opener.location.href = window.opener.location.href 刷新以winodw.showModelDialog()方法打开的窗口 window....
利用js做网页的时候常常需要用到的很强大的弹窗工具,调用得当能够遮盖你的整个页面(即使由多个iframe组成)。压缩包里面还有解决关闭子窗口时刷新父窗口的方法,很好很强大。
layer弹窗:top.layer弹窗到父页面跨域,通过postMessage方法将子页面的配置对象发送到父页面中,父页面再通过子页面的配置对象打开弹窗,对象内不能存在事件。
用iframe、弹出子页面刷新父页面iframe [removed] parent.location.reload();...子窗口刷新父窗口 [removed] self.opener.location.reload(); [removed] 刷新以open()方法打开的窗口 [removed] win
当layer以iframe层的方式弹出新的窗口(子页面),如何在子页面中访问父页面的元素和函数。 1、访问父页面元素值 var parentId=parent.$("#id").val();//访问父页面元素值 2、访问父页面方法 var ...