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=шеллы

更新時間: 25-6 月-2020

190 次觀看

開啟你的 職業 生涯

透過完成課程取得認證

開始
廣告
© . All rights reserved.