html中静态包含公共部分

发布时间:2020-07-24 15:27:11 作者:csboyty
来源:网络 阅读:823

1、采用js方法

<body>

    <div id="div"></div>

    <script>

          document.getElementById("div").innerHTML = '<object type="text/html" data="index.html" width="100%" height="100%"></object>';

    </script>

</body>


<body>    <div id="div"></div>    <script>          $("#div").load("index.html");    </script> </body>

2、采用apache等服务器,使用include
apache默认不支持SSI,可以通过修改配置文件来使其支持

搜索AddType text/html .shtml的位置,打开以下注释

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml

同时需要找到Options Indexes FollowSymLinks,在其后添上Includes

以上表示支持shtml的include命令,如果还想支持html,则需改为

AddType text/html .shtml .html

AddOutputFilter INCLUDES .shtml .html

使用办法:

建立A.html文件如下

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>include</title>
</head>
<body>
    <!--#include file="B.html" -->
 </body>
 </html>

建立B.html文件如下

<div>我是被include包含进来的</div>


推荐阅读:
  1. html中伪静态和普通html静态有什么区别
  2. HTML中如何模仿新浪部分静态页面展示

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

html 公共部分

上一篇:解决postgresql无法连接数据库的方法

下一篇:在spyder里转行的方法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》