将 .html 包含在 .html 中

发布于 2024-09-07 13:46:19 字数 191 浏览 6 评论 0原文

我使用该脚本

 <!--#include virtual="dontate.html" -->

将一个 .html 文件包含到另一个 .html 文件中,但由于某种原因没有显示。

有什么理由吗?

我将使用 WAMP 和 LAMP。

谢谢 让

I used the script

 <!--#include virtual="dontate.html" -->

to include a .html file into another .html file, but for some reason does not show up.

Any reason as to why?

I will be using WAMP and LAMP.

Thanks
Jean

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

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

发布评论

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

评论(7

囍笑 2024-09-14 13:46:19

这是使用服务器端包含。您需要在您的服务器上进行设置。尽管“注释”语法具有误导性,但它确实与 HTML 无关。

This is using server-side includes. You need to set it up on your server. Despite the misleading "comment" syntax, it really has nothing to do with HTML.

尝蛊 2024-09-14 13:46:19

如果服务器上有 php,您可以只包含 html 文件,如下所示

<?php include "donate.html"; ?>

A lamp stack has php so you should be set.

但是,服务器可能未设置为通过 php 解释器运行该文件。您可以将其设置为解析文件的任何扩展名(正在执行包含操作的文件)或将其更改为已设置为解析的内容(home.html -> home.php)

if there's php on the server you can just include the html file like so

<?php include "donate.html"; ?>

A lamp stack has php so you should be set.

However, the server may not be set up to run the file through php's interpreter. You can either set it to parse whatever the extension of the file is (being the file that is doing the including) or change it to something that is already set to be parsed (home.html -> home.php)

欢你一世 2024-09-14 13:46:19

当您使用 wamp/lamp 时,我发现了一些可行的方法:

创建一个 .htaccess 文件并将以下内容放入其中

Options FollowSymLinks Includes ExecCGI

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml 

然后将您的 html 文件扩展名更改为 .shtml (包括要包含文件的文件)

所以

<!--#include virtual="dontate.html" -->

会变成

<!--#include virtual="dontate.shtml" -->

这应该可以工作

注意

该文件与包含该文件的文件位于同一目录中,使用:

<!--#include file="dontate.shtml" -->

如果位于不同的目录中,则使用:

<!--#include virtual="folder/to/file/dontate.shtml" -->

As your using wamp/lamp I found something that will work:

creating a .htaccess file and put the following in it

Options FollowSymLinks Includes ExecCGI

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml 

Then change your html file extensions to .shtml (including the file that is to include a file)

So

<!--#include virtual="dontate.html" -->

Would become

<!--#include virtual="dontate.shtml" -->

This should work

NOTE:

The file is in the same directory as the file that is including it use:

<!--#include file="dontate.shtml" -->

If it is in a different directory use:

<!--#include virtual="folder/to/file/dontate.shtml" -->
蘑菇王子 2024-09-14 13:46:19

也许问题是使用虚拟

file参数将包含的文件定义为相对于文档路径; virtual 参数将包含的文件定义为相对于文档根目录。

http://en.wikipedia.org/wiki/Server_Side_Includes

Perhaps the problem is the use of virtual

The file parameter defines the included file as relative to the document path; the virtual parameter defines the included file as relative to the document root.

http://en.wikipedia.org/wiki/Server_Side_Includes

终止放荡 2024-09-14 13:46:19
<object data="file.html" width=400 height=200"></object>

如果没记错的话...我记得 IE 中的一些边界问题,但这对于原始集成来说应该足够了。

<object data="file.html" width=400 height=200"></object>

If memory serves... I recall some border issues in IE but that should be sufficient for a primitive integration.

半边脸i 2024-09-14 13:46:19

根据 HTML 规范,无需服务器端脚本或服务器端包含即可实现此目的的唯一方法是通过 iframe。

* 注意粗体的“仅”。

As per the HTML spec, the only way to do this without server side scripting or server side includes is via iframes.

* note the bolded 'only'.

聆听风音 2024-09-14 13:46:19

伙计们..这就是答案

// jsfile.js

var variable=""+
"";

document.write(variable);

****在 html 中包含 .js 文件****

就是这样

Guys..here is the answer

// jsfile.js

var variable=""+
"";

document.write(variable);

****include .js file in html****

thats it

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