javascript - Smooth scrolling from one page to a specific section in another page -
i building website in homepage has contact form section , other pages don't have it. using jquery, made sure when user click on contact link in navbar on homepage, page scroll down contact form section. let's user on page , clicks on contact link, want website take user homepage , scroll down contact form section. possible??
thanks answers.
you can scroll down target using id's , scroll function script below.
<script> $(document).ready(function(){ // add smooth scrolling links $("a").on('click', function(event) { if (this.hash !== "") { // prevent default anchor click behavior event.preventdefault(); var hash = this.hash; $('html, body').animate({ scrolltop: $(hash).offset().top }, 800, function(){ // add hash (#) url when done scrolling (default click behavior) window.location.hash = hash; }); } }); }); </script>
you can scroll down section need using # , href using below syntax
<a href="#section_target">click me smooth scroll section below</a>
if want target section in other page use link followed target section id
<a href="index.html#section_target">take target section in homepage</a>
target url along section id
hope looking for..
Comments
Post a Comment