1. 程式人生 > >頁頭頁尾加載方法

頁頭頁尾加載方法

pla ready arc ati pan fun psu images -c

1.PHP+JQ+HTML

HTML 

<div id="header">
    <img src="loading.gif" alt="">              //等待的gif圖
</div>
<div id="main">
    <h3>首頁</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus amet architecto asperiores culpa error, maiores natus neque officiis perspiciatis repellendus sed sunt. Eius eos molestias nihil placeat possimus sit veniam.</
p> </div>

 PHP  

header("Content-Type:text/html;charset=UTF-8");       //設置響應頭
?>
<hr>                                                  //輸出HTML代碼
<p id="copyright">版權所有? 2017-10-11</p>

JQ

<script>
    $(document).ready(fn)/*頁面加載完成後實現*/
    $(function(){         /*
頁面加載完成後實現*/ $("#header").load("footer.php") }) </script>

輸出效果:技術分享

                                                                                                  

頁頭頁尾加載方法