开发者

jquery URL modification

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜