There is a contact form at the bottom of my home page. I have a "contact" link in my navigation bar that scrolls the user down to the contact section on the home page. It works sometimes but sometimes does not scroll the user the whole way. The distance and frequency it comes up short seems to be random.
Here is the code:
$(document).ready(function() {
/*
If they reached the home page from the contact link
contact is the id of the section I want to scroll to
I get the offset of that section from the top
Then use jquerys .animate to scroll
*/
if($(location).attr('pathname') == "/contact") {
var contactOffset = $('#contact').offset().top;
var contactHeight = contactOffset
$('html body').animate({
scrollTop : contactHeight
}, 1000)
}
I followed the example from the jQuery website. What am doing that is causing the inconsistency?
Thanks in advance.