I use Javascript to change the form URL when submitting the form. If this URL contains a hash string (#), Internet Explorer ignores it and simply sends the html part before. Firefox and Chrome are fine.
Demonstration:
<script type="text/javascript"> function changeURL() { var myform = document.getElementById('myform'); myform.setAttribute("action", "page2.html#hello"); return false; } </script> <form id="myform" action="page1.html" method="get" onsubmit="changeURL()"> <input type="submit"> </form>
If I change the method to "post" then it will be fine. If I use "get", IE lands on page2.html, but without #hello in the url.
This happens whether I use jquery or just javascript, tried each of the following:
myform.action = "page2.html#hello"; myform.attr("action", "page2.html#hello"); myform.get(0).setAttribute("action", "page2.html#hello");
Any suggestions (suppose I need to save the method as "get", and that I have to use the hash in the url and that I have to use Javascript to dynamically change this action)?
source share