IE history push state

半城伤御伤魂 提交于 2019-12-01 05:46:32
Sergei Grebnov

IE9 and below doesn't support pushState. You have an exception when calling the following line

window.history.pushState(null, null, pathFullPage);

SCRIPT438: Object doesn't support property or method 'pushState' ?terms_and_conditions, line 62 character 21

You may probably be interesting looking on some workarounds discussed at Emulate/polyfill history.pushstate() in IE

Old but still current question. I just want to say I would recommend not to try to emulate pushState on IE.

Instead of that, you can use a feature detection :

  1. if history.pushState is not null (browser supports pushState), you use it and load your content with nifty javascript

  2. if history.pushState is null (browser does not support pushState), you change url / follow the link and make a full page change

Of course, this means IE<=9 users won't have all the cool animations other users have. But the question I want to ask is : do you want to see on the net links to your website containing # ?

Users may think your app is useful and paste links to it on the web. That's cool, because it brings you some google juice. Now, if that user uses IE and you use history.js, user will paste a link containing a hash.

This will defeats proper indexation of public pages of your app, and also will look ugly. My personal opinion is that having a js animation or lightbox for IE users doesn't worth those trade off.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!