當我單擊產品頁面然后轉到產品時,我在每個瀏覽器上都使用Magento 1.9.4.0。再次返回產品時,滾動位置保持不變。除了Safari,我不明白為什么它不適用于Safari。這是我嘗試使用的一些代碼,但這些都不起作用。我在Scroll.js文件中使用了此代碼。var Scroll = { mainMenuHeight: 0, init : function() { jQuery('document').ready( function() { Scroll.scroll(); Scroll.anchorClick(); Scroll.hashOnLoad(); Scroll.toTop(); }); jQuery(document).ready(function() { // If scroll location cookie is set, and the location is the same //scroll to the position saved in the scroll cookie. if ( jQuery.cookie("scroll") !== null && jQuery.cookie("location") !== null && jQuery.cookie("location") == jQuery(location).attr('href')) { jQuery(document).scrollTop( jQuery.cookie("scroll") ); } jQuery("#grid").click(function () { // Set cookie with current location jQuery.cookie("location", jQuery(location).attr('href')); // Set cookie with current scrollposition from the top jQuery.cookie("scroll", jQuery(document).scrollTop() ); }); }); },}和這個:var Scroll = { mainMenuHeight: 0, init: function() { jQuery('document').ready(function() { Scroll.scroll(); Scroll.anchorClick(); Scroll.hashOnLoad(); Scroll.toTop(); }); jQuery(function() { var pathName = document.location.pathname; window.onbeforeunload = function() { var scrollPosition = jQuery(document).scrollTop(); sessionStorage.setItem("scrollPosition_" + pathName, scrollPosition.toString()); } if (sessionStorage["scrollPosition_" + pathName]) { jQuery(document). scrollTop( sessionStorage.getItem("scrollPosition_" + pathName)); } }); },}我期望在Safari中返回時滾動位置也保持不變。它適用于某些產品,但不適用于所有產品...
在野生動物園返回時,Magento保持滾動位置
Cats萌萌
2021-04-05 21:23:18