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=.php?something=some
it reads:
url = .php?something
If its like
http://localhost/index.html?url=.php?something%3Dsome
it reads:
url = .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?
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./index.php?something=some
it reads:
url = http://www.example./index.php?something
If its like
http://localhost/index.html?url=http://www.example./index.php?something%3Dsome
it reads:
url = http://www.example./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?
-
How are you creating this URL? You should escape the whole
url
value. – Felix Kling Commented Jul 8, 2011 at 13:12
2 Answers
Reset to default 5Use the (built-in) encodeURIComponent()
function:
url = 'http://localhost/index.html?url=' +
encodeURIComponent('http://www.example./index.php?something=some');
Are you looking for encodeURIComponent
and decodeURIComponent
?