Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1206133

    Hi there,
    On the page of our client, we used anchor links.
    If you are in Chrome and on the Homepage while using the menu, the anchor link on the new page is above the view, when the page is loaded.
    Below are some links and infos, do you have any idea why this is happening?

    Thank you very much,
    Elbnetz

    #1207271

    Hey ksalewski,
    Sorry for the late reply, it looks like you are getting an early error Uncaught TypeError: Cannot read property 'innerHTML' of null from:

        jQuery(window).load(function() {
            var el = document.querySelector('.avia-caption-title');
            el.outerHTML = '<h1 class="avia-caption-title ">' + el.innerHTML + '</h1>';
        });

    This looks like a custom script, perhaps in your functions.php? Please try removing it and clearing your cache then test your menu item.
    Best regards,
    Mike

    #1207447

    Hi There,
    Thank you for the reply! I removed the script and cleared the cache, sadly the problem is still there.
    We only discovered it shortly after the update to WordPress 5.4 was made.

    Many thanks,
    Elbnetz

    #1207506

    Hi,
    I believe that the page is going to the anchor but the page is not fully loaded yet, so when the page is finished loading the position of the scroll is not correct. This seems to help.
    Try adding this code to the end of your functions.php file in Appearance > Editor:

    function custom_scroll_script(){
      ?>
      <script>
    (function($) {
      $('a[href*="#"]:not([href="#"])').click(function() {
          var target = $(this.hash);
            $('html,body').stop().animate({
              scrollTop: target.offset().top - 90
            }, 'linear');   
      });    
    	if (location.hash){
        var id = $(location.hash);
    	}
    	$(window).load(function() {
      	if (location.hash){
        	$('html,body').animate({scrollTop: id.offset().top -90}, 'linear')
      	};
     	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_scroll_script');

    Please add this function and clear your browser cache and check.

    Best regards,
    Mike

    #1207508

    Hi Mike,

    Thank you very much for the help! This worked for us!

    Best regards,
    Elbnetz

    #1207673

    Hi,

    I’m glad this was resolved. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Anchor jumps too far in Chrome’ is closed to new replies.