javascript - window.history.pushState refreshing the browser -



javascript - window.history.pushState refreshing the browser -

i working on javascript code, , using window.history.pushstate load new html pages, instead of using href tags. code (which working fine) looks this.

window.history.pushstate({urlpath:'/page1'},"",'/page1')

strangely, fails, ie reloads browser

window.history.pushstate({urlpath:'/page2.php'},"",'/page2.php')

but works, content updated, browser not refreshed ! (notice url absolute , not relative)

window.history.pushstate({urlpath:'www.domain.com/page2.php'},"",'www.domain.com/page2.php')

the documentation window.history.pushstate says 3rd parameter url can either absolute or relative -

url — new history entry's url given parameter. note browser won't effort load url after phone call pushstate(), might effort load url later, instance after user restarts browser. new url not need absolute; if it's relative, it's resolved relative current url. new url must of same origin current url; otherwise, pushstate() throw exception. parameter optional; if isn't specified, it's set document's current url.

absolute urls seem working relative seem not. why happening?

the short reply history.pushstate (not history.pushstate, throw exception, window part optional) never suggest.

if pages refreshing, caused other things doing (for example, might have code running goes new location in case of address bar changing).

history.pushstate({urlpath:'/page2.php'},"",'/page2.php') works supposed in latest versions of chrome, ie , firefox me , colleagues.

in fact can set whatever function: history.pushstate({}, '', 'so long , fish.not real file').

if post more code (with special attending code nearby history.pushstate , anywhere document.location used), we'll more happy help figure out issue coming from.

if post more code, i'll update reply (i have question favourited) :).

javascript php html browser pushstate

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -