Anchor link connect to submenu Dawn 14.0

Solved

Anchor link connect to submenu Dawn 14.0

Rio_Omnis
Tourist
27 0 2

I am not a coder but I have coded a lot of things thanks to this. My main mega menu has been coded so that if you press the actual name above the dropdown you can go visit the page dedicated to that subject. Problem I have ran into is that my submenu is connected to sections of each page. It all works but if I am in another page and try to use the dropdown to reach another anchor on another page it does not work (check link below). I need a code that will fix this current issue. Or a step by step of where to go in the code to change what I need to change.  Thank you in advance

 

Note: The version i'm working with is not the current live website.

Limitless Draft 14.0 Dawn 

https://www.loom.com/share/b6038931fdd1421da7e9540614083397?sid=4e246cbf-a4b1-4a43-babe-88459fe78c35 

Accepted Solution (1)
Sonya_2025
Shopify Partner
346 37 60

This is an accepted solution.

Hi @Rio_Omnis 

Based on the solution from Dan, you can add a script to make sure it works

 

1. Open the theme code editor and find the main-page.liquid from sections

Sonya_2025_0-1718607162400.png

 

2. Paste the code at the end of file.

<script>
  window.addEventListener("load", (event) => {
    var url = window.location.href;
    var elementIDs = url.split('#');

// Scroll the document to the element with id "divFirst"
var element = document.getElementById(elementIDs[1]);
  element.scrollIntoView(); 
});

</script>

  

Hope this helps.

 

Feel free to reach out if you need any further assistance.

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out.Get Shopify free trial 1$/mon
 EMAIL ME  Motivate me by  PAY ME

View solution in original post

Replies 5 (5)

Sonya_2025
Shopify Partner
346 37 60

Hey @Rio_Omnis 

 

you are building your store in a special way.

we normally using collection list template to achieve this. not using pages in shopify admin.

However you can do it in your way too pls following below steps:

1. Remove the submenu from menu.

2. Add the submenu data using page metafields.

3.show your submenu in the page and add anchor link function.

 

It is not easy to give your code since it is a bit complicated. Feel free to DM or Email if you need any further assistance.

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out.Get Shopify free trial 1$/mon
 EMAIL ME  Motivate me by  PAY ME
Rio_Omnis
Tourist
27 0 2

I am not well versed in metafields so this is straight forward but I do not know how to implement 

Dan-From-Ryviu
Shopify Partner
11363 2228 2400

You must add a full link to your menu instead of just "#ancho-link"

For example, instead of "#shopify-section-template--18024173240579__featured_product_6pmN6z", please add "https://limitlessmfg.com/pages/headache-rack#shopify-section-template--18024173240579__featured_prod..."

- Found this helpful? Hit "Like" and "Accept as Solution"! Support me: Donate!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify

Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.

Rio_Omnis
Tourist
27 0 2

I tried this but when I am in another page and press the submenu items on a seperate page it does not take me to the section it just takes me to the page.

Sonya_2025
Shopify Partner
346 37 60

This is an accepted solution.

Hi @Rio_Omnis 

Based on the solution from Dan, you can add a script to make sure it works

 

1. Open the theme code editor and find the main-page.liquid from sections

Sonya_2025_0-1718607162400.png

 

2. Paste the code at the end of file.

<script>
  window.addEventListener("load", (event) => {
    var url = window.location.href;
    var elementIDs = url.split('#');

// Scroll the document to the element with id "divFirst"
var element = document.getElementById(elementIDs[1]);
  element.scrollIntoView(); 
});

</script>

  

Hope this helps.

 

Feel free to reach out if you need any further assistance.

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out.Get Shopify free trial 1$/mon
 EMAIL ME  Motivate me by  PAY ME