Getting a link to go to a specific section on another page

后端 未结 5 381
刺人心
刺人心 2021-02-02 12:48

I have a link on one page that needs to go to a different page, but load to a specific section on that other page.

I have done this before with bootstrap but they take a

相关标签:
5条回答
  • 2021-02-02 13:13

    To link from a page to another section of the page, I navigate through the page depending on the page's location to the other, at the URL bar, and add the #id. So what I mean;

    <a href = "../#the_part_that_you_want">This takes you #the_part_that_you_want at the page before</a>

    0 讨论(0)
  • 2021-02-02 13:14

    I believe the example you've posted is using HTML5, which allows you to jump to any DOM element with the matching ID attribute. To support older browsers, you'll need to change:

    <div id="timeline" name="timeline" ...>
    

    To the old format:

    <a name="timeline" />
    

    You'll then be able to navigate to /academics/page.html#timeline and jump right to that section.

    Also, check out this similar question.

    0 讨论(0)
  • 2021-02-02 13:16

    You can simply use

     <a href="directry/filename.html#section5" >click me</a>
    

    to link to a section/id of another page by

    0 讨论(0)
  • 2021-02-02 13:21

    I tried the above answer - using page.html#ID_name it gave me a 404 page doesn't exist error.

    Then instead of using .html, I simply put a slash / before the # and that worked fine. So my example on the sending page between the link tags looks like:

    <a href= "http://my website.com/target-page/#El_Chorro">El Chorro</a>
    

    Just use / instead of .html.

    0 讨论(0)
  • 2021-02-02 13:25

    To link from a page to another section just use

    <a href="index.php#firstdiv">my first div</a>
    
    0 讨论(0)
提交回复
热议问题