html引入另一个html

在写页面的时候,有些东西是一样的,比如头部的导航或者尾部的标注。所以复用的东西可以写到一个文件中,之后再引入,angularjs或是jsp中都有很好的标签引入,而html没有,但是可以借助一些方式进行引入。

angularjs文件引入

 angularjs 头部引入
<head>
    <% include configHead.ejs %>
    <title>后台管理</title>
</head>

angularjs 尾部或中部引入
<% include homeFooter.ejs %>
jsp文件引入
<%@ include file="文件名" %>//(等于是将两个jsp合并为一个jsp)或
<jsp:include page="文件名">//(相当于将两个jsp执行后的内容合并成一个页面)

html文件引入

(1)Js方法  引入homeHeader.html和homeFooter.html,div使用class引入

<script type="text/javascript">

        $(document).ready(function () {

            $('.configHead').load('homeHeader.html');

            $('.configFoot').load('homeFooter.html');

        });

    </script>

</head>

<body>

<header>

 <div class="configHead">

 

(2)iframe引入 

<iframe name="" frameborder="0" scrolling="no" marginwidth="0" marginheight="0"  width="100%" height="170" src="homeFooter.html"></iframe>

(3)css引入

可以在css定义某个class,将所需要添加的东西负载上去,之后引用该class就可以了



posted @ 2017-02-24 11:16  liziyou  阅读(65980)  评论(0编辑  收藏  举报