Benalman Js 在 Ipad 中不工作。散列变化

Benalman Js does not working in Ipad. hashchange

我使用 Benalman JS 控制后退按钮 window 重定向 url 到主页。

我在普通浏览器中测试过 Android phone,它可以正常工作。 但它在 Ipad,

中不起作用

这是部分代码。

<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="jquery.min.js"></script>
<script src="jquery.ba-hashchange.min.js"></script>
<script>
// control back button
    // includes in js mean contains 
    if(!window.location.href.includes('#state')){
        history.pushState(null ,document.title, '#state'); // forwards
    }

    // Bind an event handler.
    jQuery(window).bind('hashchange', function(e) {
        window.location = _contextPath + "/home/";
    });
</script>
 </html>

我注意到在 Ipad 中 url 不会附加“#state”。 我怀疑 history.pushState 在 Ipad 中不起作用。

我该如何解决这个问题?

谢谢

我修改后问题解决了

includes

indexOf

与 Benalman Js 库无关。这个js可以排除

谢谢。