点击浏览器后退按钮 返回指定页面

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
        jQuery(document).ready(function ($) {
                     if (window.history && window.history.pushState) {
                         $(window).on('popstate', function () {
                             var hashLocation = location.hash;
                             var hashSplit = hashLocation.split("#!/");
                             var hashName = hashSplit[1];
                             if (hashName !== '') {
                                 var hash = window.location.hash;
                                 if (hash === '') {
                                     window.location.href="<%=basePath%>userCentre/userBasicInfo/${userId}.htm";
                                 }
                             }
                         });
                         window.history.pushState('forward', null, './#forward');
                     }
                 });
</script>

欢迎分享本文,转载请保留出处:前端ABC » 点击浏览器后退按钮 返回指定页面

赞 (1)
分享到:更多 ()

发表评论 0