将extarnal文件中的代码导入到HTML中

编程入门 行业动态 更新时间:2024-10-25 16:25:25
本文介绍了将extarnal文件中的代码导入到HTML中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 假设我有一个仅包含以下行的文本文件(test.txt):

< h1>文本文字文字文字文字< / h1>

是否有任何命令可以在HTML文档中调用此文本文件中的内容,因此文本文件中的内容导入调用的地方,每次显示时都显示?

示例:?????/ test.txt?解决方案我相信你的意思是询问是否存在一个允许包含文件的HTML命令。

纯HTML本身并不存在,但Apache 服务器端包含的确提供了这样的指示:

<! - #include virtual =./ test.txt - >

您将需要通过Web服务器启用SSI处理。在Apache中,你通常会调用你的文件 .shtml 或类似的东西。

Say I have a text file (test.txt) that contains only the following line:

<h1>Text text text text text</h1>

Is there any command that I can call the contents from this text file in an HTML document, so the contents in the text file imports where the call is made, every time the side shows?

Example: ?????"/test.txt"?????

解决方案

I believe you mean to ask whether there exists a "command" in HTML which allows you to include a file.

In pure HTML by itself there does not, but the Apache server-side includes does provide such a directive:

<!--#include virtual="./test.txt" -->

You will need to enable SSI processing by your webserver. In Apache, you'd typically call your file .shtml or something like that.

更多推荐

将extarnal文件中的代码导入到HTML中

本文发布于:2023-08-02 15:30:14,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:导入到   代码   文件   extarnal   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!