Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #931945

    Hi,

    We are trying to remove the #top from active menu items for mobile menu’s. What happens is the following:

    – I click on a link on a mobile device
    – When on this page, I click again on the same link
    – Result. Nothing happens and the menu does not disappear.

    This behavior can’t be reproduced in a browser with the toggle device option in the developer tools, because then the link goes to #top. We would like to reload the page when you click on a mobile menu item.

    I’ve read https://kriesi.at/support/topic/remove-hash-value-top-from-url/ but my question regards all the menu links (except the submenu’s that are intentionally added with a #)

    Link is in the private content section. Hope you can help!

    Regards,
    Dan

    #932235

    Hey Daniel,

    Here is the code you can put in your funtions.php

    
    add_action('wp_footer', 'ava_new_custom_script');
    function ava_new_custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
    	function a() {
    		if ($.avia_utilities.isMobile) {
    			var hrefTmp = jQuery(".menu-item-3295 a").attr("href");
    		
    			jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
    		}
    	}
    
    	$(window).load(function() {
    		a();
    	});
    })(jQuery);
    </script>
    <?php
    }
    

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #942482

    Hi Victoria,

    Thanks and sorry for my late reply! I see this is for one specific link (menu-item-3295). As said in my initial post, I’d like to remove #top from every active menu item, not only the home page. Can you help with that?

    Thanks!
    Dan

    #943273

    Hi,

    add_action('wp_footer', 'ava_new_custom_script');
    function ava_new_custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
    	function a() {
    		if ($.avia_utilities.isMobile) {
    			var hrefTmp = jQuery(".menu .active").attr("href");
    		
    			jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
    		}
    	}
    
    	$(window).load(function() {
    		a();
    	});
    })(jQuery);
    </script>
    <?php
    }

    Try it like that and let us know if it works

    Best regards,
    Basilis

    #944150

    Hi Basilis,

    Thanks for helping! It’s not working yet, I assume this second line also needs to be changed?

    
    			var hrefTmp = jQuery(".menu .active").attr("href");
    		
    			jQuery(".menu-item-3295 a").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
    

    I’ve now changed it to

    
    			var hrefTmp = jQuery(".menu .active").attr("href");
    		
    			jQuery(".menu .active").attr("href", hrefTmp.substr(0, hrefTmp.length-4));
    

    but it’s still not working. Any suggestions?

    #945194

    Hi,

    Thank you for the update.

    Why are you trying to remove the hash in the url? Please try this solution instead.

    // https://kriesi.at/support/topic/close-mobile-menu-by-clicking-on-active-navigation-item/#post-906654

    The modification will force the mobile menu to close if an active menu item is clicked. It will not reload the page.

    Best regards,
    Ismael

    #1237328

    if it’s still useful try this:

    
    add_action('wp_footer', 'remove_top_from_link_menu');
    function remove_top_from_link_menu(){
    ?>
    <script type="text/javascript">
    	
    	jQuery(document).ready(function() {
            
               jQuery(".av-main-nav-wrap").on("click", function(){
    
                  if (jQuery.avia_utilities.isMobile) {
                      var hrefTmp = jQuery("#av-burger-menu-ul .current_page_item a").attr("href");		
                      jQuery("#av-burger-menu-ul .current_page_item a").attr("href", hrefTmp.substr(0, hrefTmp.length-4)); 
                  }                 
              });	
    	});
    
    </script>
    <?php
    }
    
    • This reply was modified 4 years, 3 months ago by davidebord90.
    #1237433

    Hi davidebord90,

    Thank you for sharing! :)

    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.