Say I have a simple form:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="search">
<form method="GET" action="/super-action">
<input type="text" name="q" />
</form>
</div>
</body>
</html>
with input type: @tags "Cinéma Whatever"
The GET request form results in a URL that looks like this: /super-action?q=%40tags+"Cinéma+Whatever"
Now I want to reproduce this using javascript in location.hash with a pound icon instead of a slash, for example: /super-action#q=%40tags+"Cinéma+Whatever"
But with the available functions, I get the results:
- escape (input):
@tags%20%22Cin%E9ma%20Whatever%22 - encodeURI (input):
@tags%20%22Cin%C3%A9ma%20Whatever%22 - encodeURIComponent (input):
%40tags%20%22Cin%C3%A9ma%20Whatever%22 - $ (form) .serialize (), without q =:
%40tags+%22Cin%C3%A9ma+Whatever%22
Question: how can I make an input value, for example @tags "Cinéma Whatever", look like a GET form request will look like: %40tags+"Cinéma+Whatever"using javascript?
source
share