zoukankan      html  css  js  c++  java
  • a链接传参的方法

       //获取分案编号
    var hrefVal=window.location.href.split("?")[1]; //得到id=楼主
    //console.log(hrefVal+"后一个"+hrefVal[3]);
    var theRequest = new Object();
    var strs = hrefVal.split( "&" );
    //那么我们在新页面接收参数, 并且将参数转为可用的json格式时, 可以用下面的方法:
    for ( var i = 0; i < strs.length; i++ ) {
    theRequest[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );
    }
    console.log( theRequest );
    var division_code = $("#division_code span").html(theRequest.assignNo);
    //那么我们在新页面接收参数, 并且将参数转为可用的json格式时, 可以用下面的方法:
    // var url = location.search; //获取url中"?"符后的字串 ('?modFlag=business&role=1')
    // var theRequest = new Object();
    // if ( url.indexOf( "?" ) != -1 ) {
    // var str = url.substr( 1 ); //substr()方法返回从参数值开始到结束的字符串;
    // var strs = str.split( "&" );
    // for ( var i = 0; i < strs.length; i++ ) {
    // theRequest[ strs[ i ].split( "=" )[ 0 ] ] = ( strs[ i ].split( "=" )[ 1 ] );
    // }
    // console.log( theRequest ); //此时的theRequest就是我们需要的参数;
  • 相关阅读:
    [编程题]多多的数字组合
    mac传输文件到服务器
    git 清除缓存、查看add内容
    go build
    vim编辑器
    Git: clone指定分支
    查看端口占用以及kill
    curl小记录
    Python3.9 malloc error: can’t allocate region
    设计模式-策略模式
  • 原文地址:https://www.cnblogs.com/web-chuanfa/p/9101060.html
Copyright © 2011-2022 走看看