0
我使用Benalman JS來控制後退按鈕窗口重定向url到家。Benalman Js不在iPad上工作。 hashchange
我在正常的瀏覽器和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不會追加「#狀態」。 我懷疑history.pushState在Ipad中不起作用。
我該如何解決這個問題?
謝謝