javascript - Using slash in window.location.hash -
if change hash so: window.location.hash = "main/0/sub/1/na/false";
. address in browser changes http://mysite.com/#main/0/sub/1/na/false
. page's onhashchange function fires , works supposed to.
however, in firebug can see i'm sending request to: http://mysite.com/main/0/sub/1/na/false
... url without hash, results in silent 404 in console.
when debug find happens @ window.location.hash
point.
but, if change hash so: window.location.hash = "main=0&sub=1&na=false";
no additional request sent.
why additional request being sent in first example?
update: noticed sends request after window.location.hash
, before (during?) $(window).bind('hashchange')
. example if have ...
window.location.hash = 'main/0/sub/1/na/false'; // breakpoint 1 in firebug $(window).bind('hashchange', function(e) { e.preventdefault(); // breakpoint 2 in firebug e.stoppropagation(); });
when stops @ breakpoint 1, no request sent. when stops @ breakpoint 2, request sent.
i can see in apache tomcat request being sent, too.
i'll add have jquery , jquery mobile plugged in.
update 2: removing jquery mobile resolves problem. however, need :/
update 3
if interested: jquery mobile: http://jsfiddle.net/piosko/hz5pu/3/
without jquery mobile: http://jsfiddle.net/piosko/hz5pu/4/
open firebug or other debugging app , test links.
i had similar problem when using history.js. think that's intended behavior script, it's designed make urls pretty (non-hashy) while not reloading page.
Comments
Post a Comment