2015-05-18 14 views
0

我有點困惑。爲什麼我的html腳本元素吃掉了我的身體?

這裏是我的html頁面:

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
     html, body { 
      overflow: hidden; 
      width: 100%; 
      height: 100%; 
      margin: 0; 
      padding: 0; 
      } 

      #renderCanvas { 
      width: 100%; 
      height: 100%; 
      touch-action: none; 
      } 
    </style> 
    <title>Cubing</title> 
    <script src="hand.js" /> 
    <script src="cannon.js" /> 
    <script src="oimo.js" /> 
    <script src="babylon.js" /> 
</head> 
<body> 
    <canvas id="renderCanvas"/> 
    <script src="main.js" /> 
</body> 

</html> 

正如你所看到的,我使用的是babylonjs,但我懷疑的事項。

當我在瀏覽器中打開頁面並點擊F12時,我可以看到顯示的html。

這是我所看到的:

<!DOCTYPE html> 
<html> 
<head> 
    <style> 
     html, body { 
      overflow: hidden; 
      width: 100%; 
      height: 100%; 
      margin: 0; 
      padding: 0; 
      } 

      #renderCanvas { 
      width: 100%; 
      height: 100%; 
      touch-action: none; 
      } 
    </style> 
    <title>Cubing</title> 
    <script src="hand.js"> 
      <script src="cannon.js" /> 
      <script src="oimo.js" /> 
      <script src="babylon.js" /> 
     </head> 
     <body> 
      <canvas id="renderCanvas"/> 
      <script src="main.js" /> 
     </body>   

    </html> 
    </script>  
</head> 
<body></body> 
</html> 

我得到了IE和Chrome相同的結果。爲什麼變化如此之大?有關係嗎?

+0

'canvas'不是自閉的標籤。 https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/canvas#Required_ <.2Fcanvas> _tag – isherwood

回答

0

<script>標籤無法使用快捷關閉標籤。語法必須是<script src="..."></script>

+1

'!!!!!!!!!!!!HTMLTYPE HTML5 – Amit

+0

嘆*我討厭缺少標籤。 – TylerH

1

您忘記了關閉腳本標記。

更改它:

<script src="hand.js" /> 
<script src="cannon.js" /> 
<script src="oimo.js" /> 
<script src="babylon.js" /> 

要:

<script src="hand.js" /></script> 
<script src="cannon.js" /></script> 
<script src="oimo.js" /></script> 
<script src="babylon.js" /></script> 
相關問題