
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Unescape HTML Entities in JavaScript
To unescape HTML entities in JavaScript, use the unescape() function. Let's say you want to encode special character with the unescape() function ?
document.write(unescape("Demo%20Text%20"));
In this article, we will see two examples ?
- Unescape Entities
- Decode the Encoded String
Unescape Entities
Example
Lo unescape, we will use the unescape() method in JavaScript. Let us see an example ?
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <script> document.write(unescape("Demo%20Text%20")); </script> </body> </html>
Output

Decode the Encoded String
Use escape() for encoding and unescape() for decoding. Here, we will set a sample string under the escape() method to encode ?
var myStr = escape("Demo Text!!!"); document.write("Encoded String = " + myStr);
After that, we will use the unescape() to decode the encoded string ?
document.write("Decoded = " + unescape(myStr))
Example
Let us now see the example ?
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <script> var myStr = escape("Demo Text!!!"); document.write("Encoded String = " + myStr); document.write("<br>"); document.write("<hr>"); document.write("Decoded = " + unescape(myStr)) </script> </body> </html>
Output

Advertisements