Anchor link within page
-
Hi,
we found a couple of posts in the forum about anchor links but nevertheless we didn't manage to get it to work.
We added a text paragraph and gave it an id="test", we set a link to #test (without the full url) and we added this snippet to the custom head section
script> window.laytheme.on('newpageshown', function(){ if(window.location.hash.length > 0){ var id = window.location.hash; if(jQuery(id).length > 0){ jQuery('html, body').animate( { scrollTop: jQuery(id).offset().top }, { duration: 1200 }); } } }); </script>
But the link just opens a blank page and doesn't jump to the id?
Best
Andreas -
Dear @Andreas123
what exactly do you try to achieve?``Best!
Marius -
We want to have a simple sub-navigation where the can directly jump to a section of the page, you know with <p id="something> and <a href=#something">...
-
Dear @Andreas123
Did you have a look in this post? http://laythemeforum.com:4567/topic/2863/link-to-anchor-from-another-page/4
Also you can search the forum for the topic anchor links.
Best!
Marius
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it