Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Hàm decodeURI() trong JavaScript

Hàm decodeURI() giải mã một URI hoàn chỉnh đã được mã hóa bởi encodeURI(). Hàm này không giải mã được các chuỗi được mã hóa bởi encodeURIComponent() (vì encodeURIComponent mã hóa thêm các ký tự dành riêng như / ? : @ & = + $ #).

Cú pháp

Cú pháp của nó như sau:

decodeURI(encodedURI)

Ví dụ

<html> <head>    <title>Ví dụ JavaScript</title> </head> <body>    <script type="text/javascript">       var result1 = decodeURI('https://www.qries.com/');       document.write(result1);       document.write("<br>");       var result2 = decodeURI('https://www.tutorialspoint.com/');       document.write(result2);    </script> </body> </html>

Kết quả

https://www.qries.com/
https://www.tutorialspoint.com/