is it good practice to use iframe to implement header/navbar?
my website is basically 5 thousand pages but all static html (not using any content manager, php, etc.).
am in the process to add a n开发者_JAVA百科avbar at the top of each page. e.g. tabs, or crumbs, or any sort of header with js menu. (the exact design not decided yet)
my question is, is it good practice to use a iframe for this? (so, instead have same text repeated in all 5 thousand pages, each will just have a short iframe pointing to a header file)
am aware that one should reduce http request for speed, but this is ok with me. Any other problems i might have with this? SEO or any tech issue?
Using iframes to display parts of the same document is not good practice. Consider the document as a whole and that should give you the answer. Or consider that there are devices who don't do well when encountering iframes. And speaking of SEO is funny. Documents without header of footer (hence no internal links), or with just the navigation pointing to other iframe wrappers don't do well.
If your goal is to avoid using a dynamic language, how about going for SSI (Server Side Includes)?
You don't need to move to a fully dynamic solution. Consider this simple 3 step solution, assuming you are on Apache.
- add a file named .htaccess into your root directory with the text
AddType application/x-httpd-php .html
in it. This makes apache parse any php code in a html file. - Put
<?php include('header.html'); ?>
at the top of every page. - Create a single header.html page which will then show up on every other html page.
No please, dont use iframes. I'm afraid your using a bad aproach.
You need to move to something a little more advanced (nothing really complicated). Just a couple of scenarios:
- Not much of a programmer -> try Joomla (http://www.joomla.org/) Really easy, just grab a nice template and create articles (silly CMS) in order to build those mills. of pages.
- Like JAVA? Right -> try making a webapp with includes or tiles
精彩评论