"模板"适用于HTML网站 [英] "Template" of sorts for HTML website

查看:101
本文介绍了"模板"适用于HTML网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,当前位于我的服务器文件夹中的HTML文件的形式。我在每个页面上都有一些元素,并且必须是相同的,例如导航栏。当我添加一个新的链接到导航栏时,如果我想为每个页面生效,我必须绕过每个文件来替换代码。有没有办法让代码从文件中插入?我知道类似于<?php include()?>> 的可能性,但是如何在没有服务器端脚本的情况下做到这一点?

I have a website which currently resides in the form of HTML files in my server's folder. I have some elements that are present on each page, and have to be the same, e.g. the navbar. When I add a new link to the navbar, if I want to make that effective for every page, I have to go around every single file replacing code. Is there a way to make the code be "inserted" from a file? I know something like that is possible with <?php include() ?>, but how would I be able to do that without server-side scripting?

编辑:jQuery和其他库都可以。

jQuery and other libraries are fine.

推荐答案

没有服务器端就是javascript。请参阅Aviatrix的JS模板文章。

The only way to go without the server-side is javascript. See Aviatrix's post for a JS template.

在你的情况下,只有服务器端可以接受,我宁愿选择更通用的方法;而不是在每个文件/页面中放置导航栏,一次在单独的文件中创建导航栏,并在每个页面中使用它(需要使用php或其他ssi方法)。

In your case, and only if server-side IS ACCEPTABLE for you, I would rather go for a more generic approach; instead of having your navbar in each file/page, create your navbar one time in a separate file, and use it in every page (php or other ssi approach is needed).

这篇关于&QUOT;模板&QUOT;适用于HTML网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆