Link to an anchor on a different page
General Discussion
5
Posts
3
Posters
207
Views
2
Watching
-
Hi,
I’m not able to use anchors to scroll to a different sections of a page.
I think the problem is that in the code there isn’t any element with the anchor name.
I’ve tried to assign the ID to the row and to the element but it never shows in the html,
The website is under development and I can provide the access to the admin panel.
Thanks in advance
-
do you link to a different page and then to an anchor on that different page?
you can send the link to info@laytheme.com and please also send the url to this topic -
hey!
ok, I inserted this code in "lay options"→ "Custom <head> content
" and it works now:<script> //this is for making # links animate-scroll to a section that is on the same page jQuery(document).on( 'click', 'a[href^="#"]', function(e){ e.preventDefault(); var hash = jQuery(this).attr('href'); var el = jQuery(hash); var top = el.offset().top; jQuery('html, body').animate({ scrollTop: top }, 300, 'swing', function() { window.location.hash = hash; } ); } ); //this is for scrolling to a section of a different page when linking to it window.laytheme.on('newpageshown', function(){ var hash = window.location.hash; var el = jQuery(hash); if(el.length > 0) { var top = el.offset().top; window.scroll(0, top); } }); </script> -
Great to hear!
Online Users
Forgot your key, lost your files, need a previous Lay Theme or Addon version?
Go to www.laykeymanager.com