Jump to content

Linking Folders to Anchors links - ISSUE

Recommended Posts

Site URL: https://www.susanchalkermassage.com/

Hi Guys,

I have added code in my header to link my folders in my navigation to an anchor on my homepage as I have created a one pager. Only the blog ,contact form and from Lomi Lomi in the dropdown of massages all goes to its own page.

 The issue I am having is ....It works at first as you will see when you go to the site https://www.susanchalkermassage.com/ but as soon as I Click the Logo to go to homepage and try and click on the Header links (Say I go to the About page, it says "This folder does not contain any pages.").  Its also not linking on mobile at all.

Did I add something wrong in my code or am I missing something.

 

<script type="text/javascript" src="jquery-1.11.1.min.js"></script>

<!-- Redirecting Testimonial on nav -->
  <script>
Y.on('domready', function(){
Y.one('nav a[href="/testimonial"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#testimonial-home';
});
});
</script>
<!-- Redirecting About on nav -->
 <script>
Y.on('domready', function(){
Y.one('nav a[href="/about"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#susan';
});
});
</script>

<!-- Redirecting Individualized Massage on nav -->
  <script>
Y.on('domready', function(){
Y.one('nav a[href="/individualized"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#individualized-massage';
});
});
</script>

<!-- Redirecting Location on nav -->
  <script>
Y.on('domready', function(){
Y.one('nav a[href="/location"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#location-address';
});
});
</script>

<!-- Redirecting Massages on nav-->
  <script>
Y.on('domready', function(){
Y.one('nav a[href="/rates"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#massage-rates';
});
});
</script>

<!-- Redirecting massages page -->
  <script>
Y.on('domready', function(){
Y.one('nav a[href="/massages"]').on('click', function(e){
  e.preventDefault();
  e.stopPropagation();
  window.location = 'https://www.susanchalkermassage.com/#massage-modalities';
});
});
</script>




<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   
<script>
 function anchorLinks(){


      Y.all("a.Mobile-overlay-nav-item").on('click', function() {
         Y.one('body').removeClass('is-mobile-overlay-active');
      });
      Y.all("a.Mobile-overlay-folder-item").on('click', function() {
      Y.one('body').removeClass('is-mobile-overlay-active');
   });



  if(!Y.one('.collection-type-index')){

      Y.all(".Mobile-overlay-nav--primary .Mobile-overlay-nav-item:not(.Mobile-overlay-nav-item--folder')").each(function(){
      this.on("click", function(){
         var newURL = "http://"+window.location.host +(this.getAttribute('href'));
         window.location.href = newURL;
       });
    });

  }
}


function scrollToURLAnchor(){
 setTimeout(function(){
   if(window.location.hash){

     $('html, body').animate({
         scrollTop: $(window.location.hash).offset().top
     }, 600,  function () {

     });
   }
   }, 700);


}

Y.on('domready', function(){
  anchorLinks();
  scrollToURLAnchor();

  if(window.location.hash != ''){
    $('a[href*="#"].Mobile-overlay-nav-item').on('click', function(){
      var newURL = 'http://'+window.location.host +$(this).attr('href');
      window.location = newURL;
    });
  }

});

window.addEventListener('mercury:load', anchorLinks);
window.addEventListener('mercury:load', scrollToURLAnchor);

</script>

 

Link to comment
  • Replies 2
  • Views 717
  • Created
  • Last Reply
On 4/2/2020 at 11:59 AM, tuanphan said:

Oh my WORD! Thanks so much @tuanphan I completely forgot to disable ajax, its working now. Just a question why wouldn't my mobile menu work though? It's now not linking to where it should it's showing as a folder and then clicking in the folder. Do I have to add css?

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.