当我单击产品页面然后转到产品时,我在每个浏览器上都使用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中返回时滚动位置也保持不变。它适用于某些产品,但不适用于所有产品...
添加回答
举报
0/150
提交
取消