我用Benalman JS 控制窗口的后退按钮,把url重定向到首页。
我在普通浏览器和Android手机上进行了测试,它可以正常工作。但它在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上运行。
我该如何解决这个问题呢?
谢谢
发布于 2017-03-01 10:27:06
在我更改后修复的问题
includes至
indexOf与Benalman Js库无关。这个js可以排除。
谢谢。
https://stackoverflow.com/questions/42513341
复制相似问题