2017-02-10 83 views
2

這是W3-包括HTML的腳本:腳本W3-包括HTML的

<script src="http://www.w3schools.com/lib/w3data.js"></script> 

這是我div標籤其中的另一頁需要得到加載:

<div w3-include-html="today.html"> 
    <script> 
    w3IncludeHTML(); 
    </script> 
</div> 

這是我的today.html頁:

<html> 
<body> 
    <table border="2"> 
     <tr> 
     <th>School</th> 
     <th>Time</th> 
     </tr> 
     <script> 
     for(var i=0;i<8;i++) { 
     var ses="one"; 
     var time="time"; 
     document.write("<tr><td><a href='"+ses+"'>"+ses+"</a></td>"+ 
        "<td>"+time+"</td></tr>"); 
     } 
     </script> 
    </table>  
</body> 
</html> 

頁面加載時我得到的輸出爲:

div output

另一頁上的腳本不與​​W3-包括HTML的工作,而當我運行today.html分別是工作:

today.html

回答

0

我想你沒有在您的<div>標籤中提及腳本的正確路徑所以試試這個:

<div w3-include-html="today.html"> 
    <script src="http://www.w3schools.com/lib/w3data.js"></script> 
</div> 
+0

我試過了。不幫助:( –

0

在主HTML的Body標籤之前,您應該添加以下內容。

<script src="assets/js/w3data.js"></script> 
<script>w3IncludeHTML();</script> 

然後你需要更換你的today.html爲以下

<table border="2"> 
     <tr> 
     <th>School</th> 
     <th>Time</th> 
     </tr> 
     <script> 
     for(var i=0;i<8;i++) { 
     var ses="one"; 
     var time="time"; 
     document.write("<tr><td><a href='"+ses+"'>"+ses+"</a></td>"+ 
        "<td>"+time+"</td></tr>"); 
     } 
     </script> 
    </table> 

我覺得這很簡單。

不包含w3IncludeHTML();進入您的更換分區。