0

I have navbar like this :

               <ul class="dropdown-menu" role="menu">
                 <li><a href="/main_page#top_something">People</a></li>
                 <li><a href="/main_page">Main Page</a></li>
               </ul>

but when I click on "People" link, it will not position correctly, because I am loading some charts on that page. I have many section with unique id and content is loaded from JavaScript (charts).

       <section id="top_something">
         <div class= "container">
          <h2 class="blue-headings text-center"><b>Top People</b></h2>
          <div id="div_something"></div>
         </div>
        <br>
    </section>

The content of a div id="div_something" I am making in JavaScript ... I have a 10 div's like this on that main_page with unique id. I can see that when I click on a a href="/main_page#top_something" on navbar it will paste me on that section , but as soon as it loads JavaScript it will move me upper

thanks in advance

katrin
  • 26
  • 5
  • try to but extension after main_page like main_page.html#top_section – Mo Shal Oct 04 '16 at 21:37
  • I can't do that , because my main_page is a .ejs file that node.js(express) is rendering on that route – katrin Oct 04 '16 at 21:48
  • check this answer http://stackoverflow.com/questions/39884440/jquery-scroll-to-id-on-page-a-from-page-b-node-ejs/39904667#39904667 – katrin Oct 06 '16 at 20:03

1 Answers1

0

If your main_page is a directory (which it probably is) then you need to simply include a slash before the anchor name.

<a href="/main_page/#top_something">People</a>

If you have JavaScript injecting content after the page loads then you will be brought to the appropriate anchor but the page may move because the additional content added by JS will push the anchor down the page. You might consider repositioning the screen to the appropriate anchor using JS after its done injecting content.

Dave Cripps
  • 929
  • 7
  • 11