JS gets the URL and deletes the specified parameter

Source: Internet
Author: User

Returns the parameter string function Remove_arg_from_url (arg_name_removed) {//sets or gets the portion of the HREF attribute that follows the question mark.    var url = window.location.search;    var arr = [];    var query_string = "";        if (Url.lastindexof ('? ') = = 0) {//intercept var arg_str = url.substr (Url.lastindexof ('? ') +1, url.length);            if (Arg_str.indexof (' & ')! =-1) {var arr = arg_str.split (' & '); for (var i in arr) {if (arr[i].split (' = ') [0]! = arg_name_removed) {query_string = Quer                Y_string + arr[i].split (' = ') [0] + "=" + arr[i].split (' = ') [1] + "&";        }} return Query_string.substr (0, query_string.length-1); The}}//regular match function Remove_arg_from_url (name) {///from the current URL, the string starting with the number//such as: Http://www.baidu.com/s?wd=baidu&cl=3 its    Search is? wd=baidu&cl=3 var query_string = window.location.search.substr (1); If there are no parameters then return empty if (query_string! = undefined) {var reg = new RegExp (' (^|&) ' + name + ' = ([^&]        *) (&|$) ');    Return Query_string.replace (Reg, "); } return ';}

  

JS gets the URL and deletes the specified parameter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.