无需代码即可重用 Html

发布于 2024-08-09 19:05:14 字数 172 浏览 3 评论 0 原文

我正在 .net 和 ruby​​-on-rails 环境之外创建一些静态 html 页面。

我创建了一个想要在多个页面之间共享的菜单,但我想知道如何使用常规 html 结构(即没有 .net 的母版页并且没有 Rail 的布局)来完成

此操作,有没有一种方法可以在不剪切和粘贴的情况下完成此操作?

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

I created a menu 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

永言不败 2024-08-16 19:05:14

您使用什么网络服务器?您可能必须启用服务器端包含才能使用:

  1. 将站点常见元素的 HTML 保存为单独的文件。例如,您的导航部分可能会保存为navigation.html 或navigation.ssi。
  2. 使用以下 SSI 标记将该 HTML 包含在每个页面中。

     
    
  3. 在您想要包含该文件的每个页面上使用相同的代码。

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

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

江城子 2024-08-16 19:05:14

要在页面之间共享常见的 HTML 片段,您需要某种服务器端“代码”。
我知道您可以做的最简单的事情是服务器端包含,“SSI”

请参阅:http://httpd.apache.org/docs/1.3/howto/ssi.html#includeastandardfooter

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

埋情葬爱 2024-08-16 19:05:14

基本上有两个选项:框架(或 iframe)或 javascript。框架会带来很多问题,我真的不建议您走这条路。查看PURE javascript 库以获得干净简单的客户端模板。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文