jquery-address
jquery-address copied to clipboard
Path with anchor in non-HTML5 browser after form submit
Hello!
I'm having this issue using IE8 (I wouldn't use IE8, but I just wanted to make sure jquery-address works there too):
An address with an anchor that looks like http://host.com/#/page/#anchor fires the change() event twice, first with /anchor as event.value, then with /page/#anchor. As I'm using the default strict mode, it would distinguish #/anything as an URI, since it has the slash after the hash, and #anything as an anchor, since it has no slash after the hash. Right?
The problem only occurs when I submit a form that's at http://host.com/#/page/ and the address after POST is http://host.com/#/page/#anchor (the anchor pointing to the form). It does not occur when I visit the http://host.com/#/page/#anchor address directly. In this case, the change event is only fired once, with /page/#anchor as event.value, as expected.
Oh, and I'm using jquery-address-1.5, but I saw your commit history and there was no reference to this kind of issues. If you want to test this with the website I'm developing, I can send you the address in private.
Kind regards, Eric
I got the problem. The form at http://host.com/#/page/ was <form action="http://host.com/page/#anchor" method="post">. Two separate thing were happening:
- The form was being submited to
http://host.com/page/#anchor, and prior to call to$.address.state('\'), anchange()event was being fired with/anchorasevent.value. - The URL changed to
http://host.com/#/page/#anchorby jquery address, as thestateoption was set, and then a newchange()event was fired with/page/#anchorasevent.value.
To avoid this, my solution was not to set the state option for non-HTML browsers using the code below:
if (window.history.pushState) {
$.address.state('\');
}