Commit c84dd5c9 by wd

修改返回顶部方式,取消href添加#top修改链接方式返回使用JS从新定位页面位置方式。

parent c9e77004
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
?> ?>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('public_footer')->toHtml();?> <?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('public_footer')->toHtml();?>
<a href="#top" title="go to header" id="topBtn" style="display: none;"> <p title="go to header" id="topBtn" style="display: none;">
<img loading="lazy" src="<?php echo $block->getViewFileUrl('images/goTop.png'); ?>"> <img loading="lazy" src="<?php echo $block->getViewFileUrl('images/goTop.png'); ?>">
</a> </p>
<script> <script>
require([ require([
......
...@@ -21,6 +21,7 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight() ...@@ -21,6 +21,7 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
?> ?>
<script> <script>
//go to top button show
window.onscroll = function (){ window.onscroll = function (){
var top = document.getElementById("topBtn"); var top = document.getElementById("topBtn");
if (document.documentElement.scrollTop > 200 || document.body.scrollTop > 200){ if (document.documentElement.scrollTop > 200 || document.body.scrollTop > 200){
...@@ -38,6 +39,12 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight() ...@@ -38,6 +39,12 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
} }
require(['jquery'],function ($){ require(['jquery'],function ($){
//go to top button click
$('#topBtn').click(function(){
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
});
if (flag){ if (flag){
var imgH = $('.logo').height(); var imgH = $('.logo').height();
imgH= Math.ceil(imgH/3); imgH= Math.ceil(imgH/3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment