开发者

jquery url builder/parser

I'm searching for a jquery plugin for full URL manipulation (parsing, buildi开发者_如何转开发ng).

Example:

var url = 'http://mypage.com/?param=1'
var params = $.getParams(url) # {param: 1}
var newUrl = $.newUrl(url, {param:2}) # 'http://mypage.com/?param=2'

Thx.


To convert a JavaScript object into a URL parameter string you can use the jQuery param method:

$.param({a:1, b:"Test 1"}) // gets: "a=1&b=Test+1"

To parse a URL parameter string into a JavaScript object use this solution.


There is this jquery plugin https://github.com/allmarkedup/jQuery-URL-Parser that I used once. But once you console.log window.location you will see that it is not so hard to do it your self.

I never tried this one: http://urldecoderonline.com/javascript-url-decode-jquery-plugin.htm but it seems it can build URL to.

Have fun

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜