开发者

What to use instead of frames in HTML

I need to build a site in HTML. I need the top of every page to look the same (I normally 开发者_StackOverflow中文版use ASP.NET master pages). Is there any way I can get around having the same header and navigation without having the same code at the top of every page?

The site need to be SEO friendly so I would rather not use frames.

Thanks.


Is there anyway I can get around having to have the same header and navigation without having to have to have the same code at the top of every page.

Not without having the same, or similar, drawbacks as using frames.

If you want a template mechanism that doesn't depend on server side support, check out Template-Toolkit. It has a utility called ttree that will build a set of static files from your data and templates which you can then upload to hosting which doesn't have anything like SSI, PHP, Masterpages, etc.


You could kind of "compile" the website before deploying it. So, you could write the pages as PHP scripts that include the header and then "compile" them by running the scripts and deploying their outputs.


I'm not a HTML guru, however, I'm sure that it is possible to create a floating layer (using <DIV> or <SPAN> sections) that could be docked at the top of the page


Most sites are built using a web framework of some description. These essentially allow you to define templates for your site pages - e.g you can define headers, footers, menus etc which the framework will insert into your page at render time (when the page is requested). However such pages are "dynamic" and thus require a scripting environment such as perl, python, ruby, php in order to generate the requested page. There are many frameworks available for these languages; or if you're building a super simple site you could set up your own templates and use those.

If however you're limited to pure HTML, i.e static pages, then yes you're going to have to manually add the common HTML to each page if you want to avoid frames.


As a general approach, you'd usually store the header (and indeed footer, other common page sections, etc.) in a separate file and include these files on each page. Depending on the capabilities of the platform, you could even make these files intelligent, in the sense that they could alter themselves based on the "current" URL.

By using this approach, you have the benefit of only having to edit the "header", etc. in one file rather than having to search & replace across the entire site, or (worse still) manually carry out the changes on every page.

However, without know what platform you're using (ASP.NET/MVC, PHP, JSP, etc.) it's impossible to recommend anything specific.


You could use server-side includes and break the page up into Header pages, Side navigation pages and footer pages.

Then you can include these as server-side includes in each of your pages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜