无需代码即可重用 Html
我正在 .net 和 ruby-on-rails 环境之外创建一些静态 html 页面。
我创建了一个想要在多个页面之间共享的菜单,但我想知道如何使用常规 html 结构(即没有 .net 的母版页并且没有 Rail 的布局)来完成
此操作,有没有一种方法可以在不剪切和粘贴的情况下完成此操作?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用什么网络服务器?您可能必须启用服务器端包含才能使用:
使用以下 SSI 标记将该 HTML 包含在每个页面中。
在您想要包含该文件的每个页面上使用相同的代码。
参考: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:
Use the following SSI tag to include that HTML in each page.
Use that same code on every page that you want to include the file.
Reference: http://webdesign.about.com/od/ssi/a/aa052002a.htm
要在页面之间共享常见的 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
基本上有两个选项:框架(或 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.