2017-06-19 30 views
-4

*編輯: 我正在使用單頁應用程序,並且使用「ui-route」,我設法在不加載新頁面的情況下拋出不同的HTML頁面。 所以我不需要在其他頁面中包含主頁面代碼。 我希望我的問題現在更容易理解。如何檢查你是哪一頁? [HTML]

我有這個主頁: enter image description here

,但是當我去到另一個網頁我想要的標誌和菜單apear但不報價 enter image description here

這裏是主要的頁面代碼:

<body> 
 
\t <div style="text-align: center"> 
 
\t \t <img alt="adminPhoto" src="../Img/admin.png" width="300px" 
 
\t \t \t height="300px"> 
 
\t </div> 
 
\t <ul> 
 
\t \t <li><a href="#/main"><img alt="Main" src="../Ico/main.png"></a></li> 
 
\t \t <li><a href="#/manageCompanies"><img alt="Manage Companies" 
 
\t \t \t \t src="../Ico/companies.png"></a></li> 
 
\t \t <li><a href="#/manageCustomers"><img alt="Manage Customers" 
 
\t \t \t \t src="../Ico/customers.png"></a></li> 
 
\t </ul> 
 

 
\t <div ui-view></div> 
 

 
\t <div> 
 
\t \t <blockquote style="margin-left: 30%;"> 
 
\t \t \t Welcome Admin!<br /> We welcome you to try out most convenient Admin 
 
\t \t experience.<br /> Designed with the most advanced tools.<br /> Update, 
 
\t \t Delete or Create your Companies and Customers - with only one click!<br /> 
 
\t \t \t <footer> 
 
\t \t <cite>Daniel Liverant</cite> 
 
\t \t \t </footer> 
 
\t \t </blockquote> 
 
\t </div> 
 
</body>

我應該嘗試什麼方式?

回答

0

創建一個header.php或頭文件.html文件。在那裏粘貼你的菜單和標誌。然後在其他html文件中包含頁面。下面

例如:

的header.php

<!-- File 1 header.php --> 
 

 
<img src=".."/> 
 

 
<nav> 
 
<ul> 
 
<li> 
 
</ul> 
 
</nav>

內容文件

<?php 
 
include "header.php"; 
 
?> 
 

 
<blockqoute> <!-- or not? -->

希望這有助於!

+0

我不認爲這是正確的做法,我們正在談論SPA,所以我不想在每個其他頁面中包含HTML主文件,這就是UI路由和SPA的全部要點。 希望你瞭解我,也如果你可以寫在HTML/Js /角我不要PHP所有大聲笑 –

+0

@DanielLiverant請編輯您的問題,正確的語法,對不起,但如果你問這樣的模糊,並回答後開始給更多信息它不是真的工作... – Deathstorm

+0

對不起朋友,我現在編輯它,希望它更好。 –

0

include(或require)語句獲取指定文件中存在的所有文本/代碼/標記,並將其複製到使用include語句的文件中。 當您想在網站的多個頁面上包含相同的PHP,HTML或文本時,包含文件非常有用。

對於PHP創建兩個文件:

的header.php

<body> 
    <div style="text-align: center"> 
     <img alt="adminPhoto" src="../Img/admin.png" width="300px" 
      height="300px"> 
    </div> 
    <ul> 
     <li><a href="#/main"><img alt="Main" src="../Ico/main.png"></a></li> 
     <li><a href="#/manageCompanies"><img alt="Manage Companies" 
       src="../Ico/companies.png"></a></li> 
     <li><a href="#/manageCustomers"><img alt="Manage Customers" 
       src="../Ico/customers.png"></a></li> 
    </ul> 

    <div ui-view></div> 

的index.php

<?php include 'header.php';?> 
<div> 
     <blockquote style="margin-left: 30%;"> 
      Welcome Admin!<br /> We welcome you to try out most convenient Admin 
     experience.<br /> Designed with the most advanced tools.<br /> Update, 
     Delete or Create your Companies and Customers - with only one click!<br /> 
      <footer> 
     <cite>Daniel Liverant</cite> 
      </footer> 
     </blockquote> 
    </div> 
</body> 

您可以包括的header.php在您的網站的任何地方。

+0

嗨,朋友,謝謝你的回答,我回答了你之前評論過的人 - 我使用SPA和UI路由,請參閱我添加到主線程中的編輯。 –

0

我不得不這樣做的是插入

<div ui-view> -code- </div> 

內quoate代碼,這一切。

相關問題