2017-02-27 20 views
2

我創建了一個產品列表頁和有JS的該位保持URL反映了用戶在看(故後退按鈕應該回到該點頁)iphone7 JS history.replaceState

項目
setInterval(function() { 
    itm = jQuery('.my_item:visible:last').attr('id'); 
    jQuery('.my_item').each(function(){if((jQuery(this).offset().top + jQuery(this).height()) > jQuery(window).scrollTop()){ 
     itm = jQuery(this).attr('id'); 
     return false; 
    }}); 
    history.replaceState({} ,window.location.href.split('itm=')[0] , window.location.href.split('itm=')[0] + '&itm='+ itm); 
},200); 

這個工程100%在我的桌面Chrome瀏覽器和Android和iPhone 6和下但由於某種原因在iphone7這不起作用似乎URL並不總是更新,任何想法,爲什麼它不會工作?

回答

1

據我所知history.replaceState禁止在iPhone,因爲安全原因。但改變window.location.hash不是,所以你可以使用散列而不是查詢參數來實現相同的功能。

+0

它部分工作? –