The encodeURI() function is used to encode a URI.
This function encodes special characters, except: , / ? : @ & = + $ # (Use encodeURIComponent() to encode these characters).
Example
var uri = "my queryhome.com";
var res = encodeURI(uri);
Output
my%20queryhome.com