当前位置: 动力学知识库 > 问答 > 编程问答 >

html5 - HTML site navigation

问题描述:

I am starting to program in HTML5. I am doing a basic navigation menu with links to "1.html", "2.html" and so on HTML pages. The thing is that when the navigation button links me to the "1.html" page a new page appers and navigation menu is lost.

Is there a way to keep the navigation menu always on the screen? Should I copy/paste the navigation menu HTML code in every page? (I hope not)

Thanks in advance.

网友答案:

you need to keep this in mind:
if you open a html document, it will only represent its content. it cannot inherit from a so called „navigation template“ unless you provide the template with every document.

  • you could create the navigation using plain javascript and just link to the corresponding js file in every document.
  • you could use framesets or a simple iframe (wich should be avoided where possible but might solve your problem)
  • you could use a serversided preparser to glue multiple html files together and use your stuff among multiple url's
  • you could just copy and paste the menu to every document
  • you could use a task runner like grunt or equal to create your final documents through precompiling templates
  • you could request the navigation template using javascript through an xmlhttprequest (falsy known as ajax) and add it to your current document

thats the options you have.

网友答案:

If pure HTML: use iFrames for header and body (or copy/paste header code to every page)

<a href="http://stackoverflow.com" target="my-iframe">Home</a>
<a href="http://stackoverflow.com/help" target="my-iframe">Help</a>
<br/>

<iframe name="my-iframe" style="border: 0; height: 400px; width: 100%;"></iframe>
分享给朋友:
您可能感兴趣的文章:
随机阅读: