How to trigger data-nav-section from URL parameter

Viewed 16

I want when a user scans QR Code, the QR code woulddirect him to a link which link is "Up/menu", I want the URL parameter "menu" to trigger the data-nav-section and instantly direct the user to the menu section on my website. All of this is because I want to avoid the user scrolling the page until arrives at the menu section. Btw I use JavaScript.

Here is my HTML code:

    <div class="js-sticky">
        <div class="fh5co-main-nav">
            <div class="container-fluid">
                <div class="fh5co-menu-1">
                    <a href="#" data-nav-section="home">Home</a>
                    <a href="#" data-nav-section="about">About</a>
                </div>
                <div class="fh5co-logo">
                    <a href="index.html" class="header-name" data-nav-section="home"><img src="images/logo-black.png" alt="logo-image"></a>
                    <a href="index.html" class="sub-header-name" data-nav-section="home">Espresso Wine Bar</a>
                </div>
                <div class="fh5co-menu-2">
                    <a href="#" class="menu-sec" data-nav-section="menu">Menu</a>
                    <a href="#" data-nav-section="reservation">Reservation</a>
                </div>                      
            </div>
            
        </div>
    </div>
1 Answers

Well, you can just use hash and element id.

Example:

<div id="someid"></div>

And just append to your URL #someid at the end. This behavior is automatically handled by a browser.

https://somedomain.com/bla-bla#someid

Related