Hàm decodeURIComponent() giải mã một thành phần URI đã được mã hóa trước đó bởi encodeURIComponent() hoặc phương pháp tương tự, trả về chuỗi gốc.
Cú pháp
Cú pháp của nó như sau:
decodeURIComponent(encodedURI)
Ví dụ
<html> <head> <title>Ví dụ JavaScript</title> </head> <body> <script type="text/javascript"> var encodedData = encodeURIComponent('https://www.qries.com/?x=шеллы'); document.write("Dữ liệu đã mã hóa: "+encodedData); document.write("<br>"); var decodedData = decodeURIComponent(encodedData); document.write("Dữ liệu đã giải mã: "+decodedData); </script> </body> </html>
Kết quả
Dữ liệu đã mã hóa: http%3A%2F%2Fwww.qries.com%2F%3Fx%3D%D1%88%D0%B5%D0%BB%D0%BB%D1%8B Dữ liệu đã giải mã: https://www.qries.com/?x=шеллы