2017-02-23 36 views
-3

2天前,我做了一個簡單的網站,由於某種原因,它不加載任何資源,如圖像,CSS和視頻。HTML/CSS網站不加載任何資源

這裏是我的代碼:

<html lang="en" class="fa-events-icons-ready"> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>Raut</title> 
    <link rel="shortcut icon" href="//static/misc/favicon.ico"> 
    <link rel="stylesheet" href="//static/misc/styles.css"> 
    <link rel="stylesheet" href="//static/misc/btn.css"> 
</head> 

<body> 
    <video id="byiwmemes" autoplay="autoplay" loop="loop"> 
     <source src="//static/top21.mp4" type="video/mp4"> 
    </video> 
    <h1><img src="//static/misc/logo.png" class="logostyle"></h1> 
    <div id="buttons"> 
     <a href="//facebook.com/rautw" class="btn blue">Facebook</a> 
     <a href="//steamcommunity.com/id/raut__/" class="btn orange">Steam</a> 
    </div> 
</body> 

</html> 


Here's what displays in the console

+0

嘗試保持刷新按鈕並單擊清除緩存並刷新 – Nicolas

+0

在href和所有加載外部資源的位置使用絕對路徑。 –

+0

如果你在Chrome上,你將需要開發工具來做上面提到的硬刷新 – Brad

回答

1

引用靜態文件時,不要使用////用於選擇http或https與外部資源。

將每個引用//更改爲/。 例如

<link rel="shortcut icon" href="//static/misc/favicon.ico">

<link rel="shortcut icon" href="/static/misc/favicon.ico">

然而,鏈接至Facebook(外部),你可以保持爲//

編輯:全固定碼:

<!doctype html> 
<html lang="en" class="fa-events-icons-ready"> 

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>Raut</title> 
    <link rel="shortcut icon" href="/static/misc/favicon.ico"> 
    <link rel="stylesheet" href="/static/misc/styles.css"> 
    <link rel="stylesheet" href="/static/misc/btn.css"> 
</head> 

<body> 
    <video id="byiwmemes" autoplay="autoplay" loop="loop"> 
     <source src="/static/top21.mp4" type="video/mp4"> 
    </video> 
    <h1><img src="/static/misc/logo.png" class="logostyle"></h1> 
    <div id="buttons"> 
     <a href="//facebook.com/rautw" class="btn blue">Facebook</a> 
     <a href="//steamcommunity.com/id/raut__/" class="btn orange">Steam</a> 
    </div> 
</body> 

</html> 
0

挑動ga URI與//是省略只是URI計劃,並將根據頁面本身加載的方案解決方案,通常要麼httphttps,並且需要域和路徑,因此所有這些//static/…路徑將無法解析,因爲static不是域。

請參閱this answer以便快速瞭解部分URI如何解析。