Change URL parameters

前端 未结 26 2628
孤独总比滥情好
孤独总比滥情好 2020-11-22 08:40

I have this URL:

site.fwx?position=1&archiveid=5000&columns=5&rows=20&sorting=ModifiedTimeAsc

what I need is to be able to

26条回答
  •  青春惊慌失措
    2020-11-22 09:17

    Ben Alman has a good jquery querystring/url plugin here that allows you to manipulate the querystring easily.

    As requested -

    Goto his test page here

    In firebug enter the following into the console

    jQuery.param.querystring(window.location.href, 'a=3&newValue=100');

    It will return you the following amended url string

    http://benalman.com/code/test/js-jquery-url-querystring.html?a=3&b=Y&c=Z&newValue=100#n=1&o=2&p=3

    Notice the a querystring value for a has changed from X to 3 and it has added the new value.

    You can then use the new url string however you wish e.g using document.location = newUrl or change an anchor link etc

提交回复
热议问题