paperjam paperjam - 9 months ago 260
HTML Question

Multiple distinct pages in one HTML file

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 : click here for page 2


Page 2 : click here for page 1

Can I create a single HTML file that embeds simple static HTML for both pages but only displays one at a time? My actual pages are of course more complicated with images, tables and javascript to expand table rows. I would prefer to avoid too much script code. Thanks!


Well, you could, but you probably just want to have two sets of content in the same page, and switch between them. Example:

function show(shown, hidden) {
  return false;

  <div id="Page1">
    Content of page 1
    <a href="#" onclick="return show('Page2','Page1');">Show page 2</a>

  <div id="Page2" style="display:none">
    Content of page 2
    <a href="#" onclick="return show('Page1','Page2');">Show page 1</a>


(Simplififed HTML code, should of course have doctype, etc.)