当前位置: 代码迷 >> HTML/CSS >> 二个html页面传值
  详细解决方案

二个html页面传值

热度:313   发布时间:2012-08-26 16:48:06.0
2个html页面传值
1.html

<script type="text/javascript">
  function onUrl(id){
   window.location.href="${base}/html/2.html?typeId=1";
     }
</script>

2.html

var strHref=location.search;
 var id=getArgsFromHref(strHref,'typeId');

alert(id);

getValue.js

function getArgsFromHref(sHref, sArgName)

{ var args  = sHref.split("?");var retval = "";

   if(args[0] == sHref){

    return retval;}

     var str = args[1];

     args = str.split("&");

      for(var i = 0; i < args.length; i ++)

      {str = args[i];var arg = str.split("=");

       if(arg.length <= 1) continue;

       if(arg[0] == sArgName)

         retval = arg[1];

        }return retval;}

?
  相关解决方案