Using history.pushstate in IE9

孤街醉人 提交于 2019-11-29 08:55:53

Your code does exactly what you'd expect it to.

window.location.pathname + '?page=1'

Prints out the location pathname (test.html), and appends ?page=1

Remove window.location.pathname and it should work.

You need to set up a client-side redirect for IE. Assuming the user lands at this page:

http://localhost/development/flipV5.html?issue=20121220&page=1

They need to be sent to

http://localhost/development/flipV5.html#?issue=20121220&page=1

The reason is that IE <= 9 doesn't let you modify anything before the hash, without sending the user to a new page. It's an old security feature preventing changing the URL to facebook.com, when you're really on spambook.com. Recently, people have realized that that's overkill.

The redirect looks like this:

<!--[if LTE IE 9]>
<script type="text/javascript">
if (location.search) 
    location.href = location.pathname + "#" + location.search;
</script>
<![endif]-->

You can now push states, and they won't show up in both the search and the hash (that's after the ? and # respectively)

Just remove window.location.pathname from History.pushState

History.pushState(null,null,'?page=1');

Maybe try:

History.replaceState(null,null,'?issue=' + currPageIssueNo + '&page=' + pageNo);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!