With the script I'm making, jquery is getting vars from url parameter. The value that its getting is an url so if its something like
http://localhost/index.html?url=http://www.example.com/index.php?something=some
it reads:
url = http://www.example.com/index.php?something
If its like
http://localhost/index.html?url=http://www.example.com/index.php?something%3Dsome
it reads:
url = http://www.example.com/index.php?something%3Dsome
which would register as a valid url. my question is how can I search for =
sign in the url
variable and replace it with hex %3D
with jquery or javascript?
Use the (built-in) encodeURIComponent()
function:
url = 'http://localhost/index.html?url=' +
encodeURIComponent('http://www.example.com/index.php?something=some');
Are you looking for encodeURIComponent
and decodeURIComponent
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.