开发者

Html reuse without code

开发者 https://www.devze.com 2022-12-10 03:15 出处:网络
I am creating some static html pages outside a .net and outside a ruby-on-rails environment. I created a m开发者_运维问答enu I want to share between several pages, but I\'m wondering how this is done

I am creating some static html pages outside a .net and outside a ruby-on-rails environment.

I created a m开发者_运维问答enu I want to share between several pages, but I'm wondering how this is done using regular html constructs (i.e. without .net's master pages and without rail's layouts)

Is there a way to do this without cutting and pasting?


What web server are you using? It's likely you'll have to enable Server Side Includes in order to use:

  1. Save the HTML for the common elements of your site as separate files. For example, your navigation section might be saved as navigation.html or navigation.ssi.
  2. Use the following SSI tag to include that HTML in each page.

      <!--#include virtual="path to file/include-file.html" -->
    
  3. Use that same code on every page that you want to include the file.

Reference: http://webdesign.about.com/od/ssi/a/aa052002a.htm


To share common HTML snippets between pages, you'll need some sort of server-side "code".
The simplest thing you could do that I know if would be Server Side Includes, "SSI"

see: http://httpd.apache.org/docs/1.3/howto/ssi.html#includingastandardfooter


There are basically two options: frames (or iframes) or javascript. Frames come with a whole host of problems and I really don't recommend you go down this route. Have a look at PURE javascript library for clean and simple client-side templating.

0

精彩评论

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