Multiple distinct pages in one HTML file

后端 未结 12 993
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 10:05

Is there any way to have multiple distinct HTML pages contained within a single HTML file? For example, suppose I have a website with two pages:

Page 1 : cl         


        
12条回答
  •  [愿得一人]
    2020-12-04 10:54

    Let's say you have multiple pages, with id #page1 #page2 and #page3. #page1 is the ID of your start page. The first thing you want to do is to redirect to your start page each time the webpage is loading. You do this with javascript:

    document.location.hash = "#page1";
    

    Then the next thing you want to do is place some links in your document to the different pages, like for example:

    Click here to get to page 2.
    

    Then, lastly, you'd want to make sure that only the active page, or target-page is visible, and all other pages stay hidden. You do this with the following declarations in the

提交回复
热议问题