The encodeURI() function is used to encode a URI.
This function encodes special characters, except: , / ? : @ & = + $ #
Eg:
Demo
This function encodes special characters, except: , / ? : @ & = + $ #
Eg:
<script>Final code and demo is here
var URL = "https://www.example.com/p/online-html-editor.html?filename=How to encode a URL in JavaScript";
var EncodedURL = encodeURI(URL);
</script>
Demo
No comments:
Post a Comment