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就是我們需要的參數;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM