-1
我怎樣才能得到額外的獲取參數在js中的href? 我想刪除url中的refer_id = xxx,然後爲它添加一個新的refer_id = xxx get參數。該網址不是唯一的。
有沒有快速的方法來做到這一點?我怎樣才能得到額外的獲取參數在js中的href?
// http://www.newpm.com/
// http://www.newpm.com/?refer_id=100
// http://www.newpm.com/index.php?main_page=product_info&refer_id=100
// http://www.newpm.com/index.php?main_page=product_info&refer_id=100&from_home
// http://www.newpm.com/index.php?refer_id=100&from_home
例如:
// http://www.newpm.com/index.php?main_page=product_info&refer_id=100&from_home
更換refer_id = XXX GET:
// http://www.newpm.com/index.php?main_page=product_info&&from_home
替換URL具有 「& &」,然後添加一個新refer_id
// http://www.newpm.com/index.php?main_page=product_info&from_home&refer_id=200
使用'window.location.search =「queryString」'。查詢字符串表示URL中'?'後面的內容。 – SeinopSys
目前還不清楚你問的是什麼問題。你在問如何從當前頁面的URL中解析查詢參數嗎?或者你問如何使用javascript在頁面中的現有鏈接上更改href。 – jfriend00
@ DJDavid98不是100%準確......'alert(location.search)'會返回'?' – charlietfl