JavaScript 中的 decodeURIComponent() 函数
decodeURIComponent() 函数接受一个表示编码的 URI(Uniform Resource Identifier)的字符串值,对其进行解码并返回结果。
语法
它的语法如下
encodeURIComponent('http://www.qries.com/');
示例
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var encodedData = encodeURIComponent('http://www.qries.com/?x=шеллы'); document.write("Encoded Data: "+encodedData); document.write("<br>"); var decodedData = decodeURIComponent(encodedData); document.write("Decoded Data: "+decodedData); </script> </body> </html>
输出
Encoded Data: http%3A%2F%2Fwww.qries.com%2F%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B Decoded Data: http://www.qries.com/?x=шеллы
广告