日期:2014-05-17  浏览次数:20968 次

求助:将index.htm的参数传递给里面的iframe
例如:

地址如果是index.htm?PPid=1234,那么里面的iframe地址就是
product.aspx?id=1234

地址如果是index.htm?PPid=1111,那么里面的iframe地址就是
product.aspx?id=1111

------解决方案--------------------
假设以下页面 是 index.htm, 访问的时候 用 http://xxxx/../index.htm?PPID=1111

index.htm:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<script>
function getItem(sid){
var s = location.search;
s = s.substr(1,s.length-1);
var p = s.split( "& ");
var a, r= " ";
for(var i=0;i <p.length;i++){
a = p[i].split( "= ");
if(a[0] == sid){
r = a[1];
break;
}
}
return r;
}
function doit(){alert(getItem( "PPID "));
document.frames[ "I1 "].location.href= "http://qixi.it.com.cn/index.aspx?PPID=? " + getItem( "PPID ");
}
</script>
</head>

<body onload= "doit(); ">
<iframe name= "I1 " marginwidth= "1 " marginheight= "1 " height= "550 " width= "875 " border= "0 " frameborder= "0 " src= " " target= "_blank "> </iframe>
</body>
</html>