Say I have a simple form like this:
<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 an input like: @tags "Cinéma Whatever"
a form GET request results in a url that looks like: /super-action?q=%40tags+"Cinéma+Whatever"
Now I want to reproduce that with javascript in location.hash, with a pound sign instead of a slash, like: /super-action#q=%40tags+"Cinéma+Whatever"
But with the available functions, I get there 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
The question: How can I make an input value, like @tags "Cinéma Whatever"
, look like what a form GET request would do: %40tags+"Cinéma+Whatever"
using javascript?