Iframe之间及iframe与父窗体之间值的传递
2024-10-19 02:20:19
方法一:ScriptManager.RegisterClientScriptBlock(this,typeof(Page), "NoInformation", "window.parent.frames['Add'].location.reload();", true); 此: 会弹出页面刷新错误
方法二: ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "NoInformation", "window.parent.frames['Add'].location.href='DepartAdd.aspx';", true); 最好的方法 可解决跳转刷新后窗体样式的改变。
参考:
(一)父窗体调用iframe子窗体的例子:
1、
//将子iframe中text的值赋给父窗体中一个text
document.getElementById('applyDate').value=window.frames["capitalList"].document.all('applytime').value;
2、
//父窗体中的一个按钮onclick触发子iframe中form的button1服务器端事件
window.frames(“capitallist”).document.forms.item(0).button1.click();或写作:
window.frames(“capitallist”).document.form1.button1.click();
注:我测试上面两个写法不好用不知啥原因
注:我测试上面两个写法不好用不知啥原因
但是使用下面的方法可以
function regedit()
{
document.frames["iframe1"].document.getElementById("tb_name").value=document.getElementById("TextBox1").value;
document.frames["iframe1"].document.getElementById("tb_pwd").value=document.getElementById("TextBox2").value;
document.frames["iframe1"].document.getElementById("btn_zc").click();
//frame.document.getElementById("btn_zc").onclick();
{
document.frames["iframe1"].document.getElementById("tb_name").value=document.getElementById("TextBox1").value;
document.frames["iframe1"].document.getElementById("tb_pwd").value=document.getElementById("TextBox2").value;
document.frames["iframe1"].document.getElementById("btn_zc").click();
//frame.document.getElementById("btn_zc").onclick();
}
<input type="button" value="注册" id="btn_reg" onclick="regedit()" />
<input type="button" value="注册" id="btn_reg" onclick="regedit()" />
(二)iframe子窗体调用父窗体的例子:
1、
//子iframe中的form的button的onclick事件给父窗体的一个text赋值
window.parent.document.all('applyDate').value=document.getElementById('applytime').value;
2、
//子页面调用父窗体的某个按钮的按钮事件
window.parent.form1.button1.click()
window.parent.form1.button1.click()
(三)iframe子窗体之间相互调用
//右边iframe中页面的按钮调用左边的iframe中的页面,让左边页面得以刷新
parent.frame(“menu”).window.location.reload();
请看下面简单例子,不多解释.
父窗体:test.htm
1 <span style="font-size: small;"><span style="color: #000000;"><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 //改变iframe中的元素id为myH1的内容 8 window.frames["iframe_text"].document.getElementById("myH1").innerHTML = "http://www.pint.com"; 9 } </script> </HEAD> <BODY> <iframe height="350" width="600" src="iframe_text.htm" name="iframe_text"></iframe> <form action="" method="post"> <input name="haha" id="haha" type="text" maxlength="30" value="haha" /><br /> <textarea cols="50" rows="5" id="getAttributeMethod"></textarea> <input type="button" onClick="show();" value="提交"/> </form> <h2 id="myH2">d</h2> </BODY> </HTML></span></span><br><span style="font-size: small;"><span style="color: #000000;">iframe的页面内容: <br></span></span>
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
6 <title>无标题文档</title>
7 </head>
8 <script language="javascript">
9 function show(){
//改变父窗体中的元素id为myH2的内容
parent.document.getElementById("myH2").innerHTML =
"http://www.adsf.com";
}
</script>
<body>
<h1 id="myH1">ha</h1>
<form action="" method="post">
<input name="abc" id="abc" type="text" maxlength="30" value="abc" /><br
/>
<textarea cols="50" rows="10" id="text"></textarea> <br />
<input type="button" value="提交" onclick="show();"/>
</form>
</body>
</html></span></span>
最新文章
- js判断网页是否加载完毕 包括图片
- excel小技巧
- C++面试题汇集
- 解决 Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
- Spring学习笔记(1)——资源加载
- Xcode5 取消ARC
- 直接把数据库中的数据保存在CSV文件中
- Hibernate,JPA注解@SecondaryTable
- 如何判断单选按钮radio被选中
- 初识 .NET平台下作业调度器——Quartz.NET
- 转:搭建Hive的图形界面
- SAX解析
- java中dao层的通用层,通过反射机制,操作数据库的增删改,适用的范围是不包含属性类
- YC(Y Combinator)斯坦福大学《如何创业》课程要点记录(粗糙)
- linux系统查询命令
- 仿爱奇艺视频,腾讯视频,搜狐视频首页推荐位轮播图(二)之SuperIndicator源码分析
- 超越村后端开发(2:新建models.py+xadmin的引入)
- django——模板层
- 【转】Asp.NetMve移除HTTP Header中服務器信息Server、X-AspNet-Version、X-AspNetMvc-Version、X-Powered-By:ASP.NET
- ubuntu上virtualbox无法找到usb设备【解决】
热门文章
- C#中&;与&;&;的区别
- codeforces C. Prime Swaps
- Unity 用C#脚本读取JSON文件数据
- jQuery Validate 验证,校验规则写在控件中的具体例子
- [LeetCode#104, 111]Maximum Depth of Binary Tree, Minimum Depth of Binary Tree
- Poetize6: Acting Cute
- 【转】基于 Android NDK 的学习之旅-----数据传输(引用数据类型)
- 搭建ftp环境
- 饭卡 (背包01 一维数组) http://acm.hdu.edu.cn/showproblem.php?pid=2546
- 《算法问题实战策略》-chaper8-动态规划法