IE7 window.location.href

谁说胖子不能爱 提交于 2019-12-24 10:25:36

问题


I want to redirect a IE7 user, but window.location.href does not seen to work properly.

Any suggestion?

$('.navigation-next a').bind('click', function (a) {
    a.preventDefault();
    window.location.href = $(this).attr('href')
})

Worked with:

$('.navigation-next a').bind('click', function(a) {
   location.href = $(this).attr('href')
})

Thanks!


回答1:


You have to use window.location.replace() on IE7 and earlier.

<script type="text/javascript">
    function redir(url){ window.location=url; }
</script>

<!--[if lte IE 7]>
<script type="text/javascript">
    function redir(url){ window.location.replace(url); }
</script>
<![endif]-->

This is why all web developers should drop support for IE until Microsoft fixes it!



来源:https://stackoverflow.com/questions/9180276/ie7-window-location-href

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