JavaScript URL解码功能

JavaScript URL解码功能

什么是最好的JavaScript URL解码实用程序?编码也会很好,并且与jQuery一起使用是一个额外的好处。



精慕HU
浏览 541回答 3
3回答

HUX布斯

我也使用了encodeURIComponent()和decodeURIComponent()。

慕沐林林

这是一个完整的函数(取自PHPJS):function urldecode(str) {    return decodeURIComponent((str+'').replace(/\+/g, '%20'));}

蝴蝶刀刀

decodeURIComponent(mystring);您可以使用以下代码获取传递的参数://parse URL to get values: var i = getUrlVars()["i"];function getUrlVars() {&nbsp; &nbsp; var vars = [], hash;&nbsp; &nbsp; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');&nbsp; &nbsp; for (var i = 0; i < hashes.length; i++) {&nbsp; &nbsp; &nbsp; &nbsp; hash = hashes[i].split('=');&nbsp; &nbsp; &nbsp; &nbsp; vars.push(hash[0]);&nbsp; &nbsp; &nbsp; &nbsp; vars[hash[0]] = hash[1];&nbsp; &nbsp; }&nbsp; &nbsp; return vars;}或者这个单线来获取参数:location.search.split("your_parameter=")[1]
打开App,查看更多内容
随时随地看视频慕课网APP