开发者

jquery URL modification

开发者 https://www.devze.com 2023-03-04 23:48 出处:网络
How do I replace subcomponents of a URL using jquery.urldecoder ? I can extract eg. the anchor using: var res = $.url.parse(myurl);

How do I replace subcomponents of a URL using jquery.urldecoder ?

I can extract eg. the anchor using:

    var res = $.url.parse(myurl);
    alert(res.anchor);

I would expect to be able to replace the anchor using:

    res.anchor = 'MyAnchor';
    alert($.url.build(res));

But the anchor part of the URL remains unchanged. I would love an example on how to examine if parameter 'language' exi开发者_如何学编程sts. Replace its value if it does, append a language with value, if it doesn't.


Are you trying to achieve something like this?

http://jsbin.com/ikasu5/5/edit

Just search the lang in the query string, substitute if not the correct one and reload the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消