父页给iframe传参数的方法

我们开发当中会遇到一些需要使用iframe的时候,一般的写法是:

<iframe name="enventApplyIframe" id="enventApplyIframe" marginheight="0" marginwidth="0" frameborder="0" height="0" width="0" scrolling="no"  src="eventInsurealarmAction.jsp"></iframe>

但有时头疼的是包含这个iframe的父页需要控制它,如父页里有查询条件区,而显示页在iframe里。这是就会出现怎么把这些条件给iframe里并且运行的问题。

为了容易理解直接直接写一个例子吧。

view plaincopy to clipboardprint?
 
<html> 
 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" /> 
 
<title>iframe</title> 
 
</head> 
 
 
 
<body> 
 
<form id="form1" name="form1" method="post" action=""> 
 
  sex:<input name="sex" type="text" id="sex" size="15" /> 
 
  age:<input name="age" type="text" id="age" size="15" /> 
 
  <input type="button" name="Submit" value="button" οnclick="javascript:goIframe();" /> 
 
</form> 
 
 
 
<iframe name="result" id="result" marginheight="0" marginwidth="0" frameborder="0" height="500" width="500" scrolling="no"  src="result.jsp"></iframe> 
 
 
 
</body> 
 
</html> 
 
 
 
<script language="javascript"> 
 
 
 
function goIframe(){  
 
    var form = document.form1;  
 
    var sex = form.sex.value;  
 
    var age = form.age.value;  
 
    var ifr = document.all("result");  
 
    window.result.location.href=ifr.src +"?sex=" + sex + "&age=" + age;  
 
    //window.result.location.href=search.do +"?sex=" + sex + "&age=" + age;  
 
}  
 
 
 
</script> 


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/dinglinhu/archive/2008/06/24/2582666.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值