JavaScript decodeURI() 函数
decodeURI函数语法
decodeURI(str);
decodeURI函数参数
- str -- 编码的字符串
decodeURI函数返回值
还原(解码)encodeURI函数编码的字符串
decodeURI函数说明
decodeURI是一个全局函数,用于解码encodeURI编码的字符串
示例
varstr="梦之都 http://www.dreamdu.com/";str=encodeURI(str);document.write(str);str=decodeURI(str);document.write(str);str=encodeURI(";/?:@&=+$,#-_.!~*'()");document.write(str);str=encodeURIComponent(";/?:@&=+$,#-_.!~*'()");document.write(str);
结果:
%E6%A2%A6%E4%B9%8B%E9%83%BD%20http://www.dreamdu.com/ 梦之都 http://www.dreamdu.com/ ;/?:@&=+$,#-_.!~*'() %3B%2F%3F%3A%40%26%3D%2B%24%2C%23-_.!~*'()
JavaScript decodeURI() 函数示例 -- 可以尝试编辑
decodeURI函数异常
- URIError -- str中含有格式化错误的转义序列,无法解码
延伸阅读
- JavaScript encodeURIComponent() 函数
- JavaScript decodeURIComponent() 函数
- JavaScript encodeURI() 函数