Javascript examples for Browser Object Model:Window atob
The atob() method decodes a base-64 encoded string which has been encoded by the btoa() method.
Parameter | Description |
---|---|
encodedStr | Required. The string which has been encoded by the btoa() method |
A String, representing the decoded string
The following code shows how to Decode a base-64 encoded string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . j a v a2 s . c om*/ var str = "Hello World!"; var enc = window.btoa(str); var dec = window.atob(enc); var res = "Encoded String: " + enc + "<br>" + "Decoded String: " + dec; document.getElementById("demo").innerHTML = res; } </script> </body> </html>