javascript - Scroll to position on another page when links already have anchor to scroll -


i have menu on home page scrolls id positions:

<li><a href="#event-section">el evento</a></li> <li><a href="#asistentes-section">asistentes</a></li> <li><a href="#contact-section">contacto & inscripciones</a></li> 

i'm using script smooth scrolling:

var $root = $('html, body'); $('a').click(function() {     $root.animate({         scrolltop: $( $.attr(this, 'href') ).offset().top     }, 500);     return false; }); 

this works perfectly.

the problem have page in site. when user enters , click on link of menu, doesn't work since divs exists on home page. want if user in other page , clicks on link of menu home page opens going section.

any idea how can fix menu able both things?

try adding index.html hash below in other pages except homepage. should work.

<li><a href="index.html#event-section">el evento</a></li> 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -