日期:2014-05-16  浏览次数:20317 次

有关用js在两个页面传参数的问题~~~
从a.html跳转到b.html页面,同时传一个参数过去。我现在已经实现这些功能,但是这个b.html是新打开的,我想让b.html页面代替a.html,请问该如何实现?具体请看代码和注释:

  a.html:
JScript code

      function openPage2(value){    //在a.html页面里调用这个函数,新打开b.html,同时把value传过去
.org/TR/xhtml1/DTD/xh


b.html:
JScript code
 
    Ext.onReady(function(){  //打开b.html后,会自动加载这个函数
      var data = window.opener.passToPage2.staffId;//获得传过来的值,这个功能已经实现
    }


  也就是说,现在可以调到b.html,也可以传值,但是b.html是新打开的,我想让b.html在原来的窗口打开,却无法实现。我试过已下写法,测试未通过:
JScript code

     window.open('http://127.0.0.1:8080/pm/html/b.htmlnhttp://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>

<style type="text/css">
*{ padding:0; margin:0; font-size:18px; font-family:Arial, Helvetica, sans-serif;}
body{background-color:#fff; }
div {border:1px solid red; display:none}
</style>
<script type="text/javascript">
window.onload=function(){
    var arrID=new Array('a','b','c','d')
  var arr=top.arr, t=0,id=0;
  for(var i=0;i<arr.length;i++){
        id=arr[i]>t?i:id;        t=arr[i]>t?arr[i]:t;        
    }
  document.getElementById(arrID[id]).style.display="block";
}
</script>
</head>

<body>
<div id=a>aaaaaaaaaaaaaaaa</div>
<div id=b>bbbbbbbbbbbbbbbb</div>
<div id=c>cccccccccccccccc</div>
<div id=d>dddddddddddddddd</div>
</body>
</html>



------解决方案--------------------
换一种方法实现跨页面js传参 否则实现不了
------解决方案--------------------
把参数写在地址栏 或者POST提交
 _self的时候只能这样。 不过也可以用COOKIE。。。。。。
------解决方案--------------------
function openPage2(value){ //在a.html页面里调用这个函数,新打开b.html,同时把value传过去 passToPage2.staffId=value; window.open(); }


window.location.href='http://127.0.0.1:8080/pm/html/b.html?staffId='+value;

不就可以了