So I've got a form with a submit button and a text input...
I want: http://localhost/
to become: http://localhost/#q=
I did a solution in javascript which involves changing the "action" of the form to the url with the hash onclick.. but this doesn't work in IE.
Anyone have a solution that works on all browsers?
So I've got a form with a submit button and a text input...
I want: http://localhost/
to become: http://localhost/#q=
I did a solution in javascript which involves changing the "action" of the form to the url with the hash onclick.. but this doesn't work in IE.
Anyone have a solution that works on all browsers?
Share Improve this question asked Jul 30, 2009 at 0:41 rawrrrrrrrrrawrrrrrrrr 3,6877 gold badges29 silver badges33 bronze badges2 Answers
Reset to default 9I ran into a similar problem with IE not pulling in the hash from the form action.
I had a form
<form action="/#search" id="search-form">
<input type="text" class="search-query" placeholder="Search" name="q">
</form>
When I submitted this form in anything but IE the page went to
/?q=searchparams#search
But in IE it went to
/?q=searchparams
To solve this I used JQuery to bind to the submit action and redirect to the page I wanted it to go to.
$("#search-form").submit(function() {
var query = $('input[name="q"]').val();
window.location.href = 'index.php?q='+query+'#search';
return false;
});
It's been working fine since.
<script>
function add_hash() {
window.location.hash = "q=";
}
</script>
<form onsubmit="add_hash(); return false;">
Not sure what you're doing with this, though.