Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Link to Anchor from another page

Link to Anchor from another page

Scheduled Pinned Locked Moved General Discussion
24 Posts 7 Posters 8.1k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mariusjopenM mariusjopen

    Dear @pmpm
    can you post the JS code which you use?

    Best!

    Marius

    P
    P
    pmpm
    wrote on last edited by
    #21

    @mariusjopen straight out of the youtube tutorial:

    <script>
        
        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
            }, 1200, 'swing',
                function() {
                    window.location.hash = hash;
                }
            );
        } );
        
        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>
    
    1 Reply Last reply
    0
    • mariusjopenM
      mariusjopenM
      mariusjopen
      Global Moderator
      wrote on last edited by
      #22

      Dear @joeclarkx

      <script>
          
          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+80;
              jQuery('html, body').animate({
                  scrollTop: top
              }, 1200, 'swing',
                  function() {
                      window.location.hash = hash;
                  }
              );
          } );
          
          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>
      

      Best!

      Marius

      www.mariusjopen.world

      P 1 Reply Last reply
      0
      • mariusjopenM mariusjopen

        Dear @joeclarkx

        <script>
            
            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+80;
                jQuery('html, body').animate({
                    scrollTop: top
                }, 1200, 'swing',
                    function() {
                        window.location.hash = hash;
                    }
                );
            } );
            
            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>
        

        Best!

        Marius

        P
        P
        pmpm
        wrote on last edited by
        #23

        Dear @mariusjopen Thanks a lot! It turned out that the script didn't even apply. So now it also works without the js and I found a solution to come to the right position with an empty textfield which contains the id above the image. This works great. But only in Firefox and Chrome. In Safari it seems like the scroll-position is not identical with other browsers. Do you have any clue what the problem could be there?

        1 Reply Last reply
        0
        • mariusjopenM
          mariusjopenM
          mariusjopen
          Global Moderator
          wrote on last edited by
          #24

          Dear @joeclarkx
          happy you managed!

          How can I see your anchor links in action?

          Best!
          Marius

          www.mariusjopen.world

          1 Reply Last reply
          0
          • S sofiapapa08 referenced this topic on
          • P person5 referenced this topic on

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          Online Users
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search