大佬教程收集整理的这篇文章主要介绍了jquery – 如何从另一个页面重定向后将页面滚动到一个元素?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<script> $(document).ready(function () { $("#button").click(function () { window.LOCATIOn.href = "page2.aspx"; $('html,body').animate({ scrolltoElement ("#div").offset().top },2000); }); }); </script>
<a name="scroll"></a> <h2>I wAnna scroll here</h2>
并链接到它:http://mydomain.com/index.PHP#scroll
使用jQuery完成此任务的唯一好处是为滚动本身设置动画,在这种情况下,您可以执行以下操作:
<h2 id="scrollhere">I wAnna scroll here</h2>
链接到这里:http://mydomain.com/index.PHP#scrollhere
$(document).ready(function() { if (window.LOCATIOn.hash != null && window.LOCATIOn.hash != '') $('body').animate({ scrollTop: $(window.LOCATIOn.hash).offset().top },1500); });
以上是大佬教程为你收集整理的jquery – 如何从另一个页面重定向后将页面滚动到一个元素?全部内容,希望文章能够帮你解决jquery – 如何从另一个页面重定向后将页面滚动到一个元素?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。