【发布时间】:2014-09-09 15:11:28
【问题描述】:
当远程文件不可用时,我正在尝试加载本地 css 和 js 文件。 (wifi断开) 主要问题是“我不知道如何让 css 正确加载”。 据我所知,jquery 应该放在正文底部以减少页面加载时间。 在浏览器的地址栏中,我输入 localhost:8000//example.html(使用静态网页浏览器)。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Go By Example - Google Go (golang) code examples" />
<link rel="icon" href="favicon.ico">
<title>Go by Example - Google Go (golang) code examples</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
</head>
<body>
<span class="glyphicon glyphicon-flash"></span>
...
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<script id="bsscript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script>$("#bsscript").load("js/bootstrap.min.js")</script>
</body>
</html>
铬的输出错误信息
GET file://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css net::ERR_FILE_NOT_FOUND local.html:9
GET file://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css net::ERR_FILE_NOT_FOUND local.html:10
GET http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js net::ERR_INTERNET_DISCONNECTED local.html:16
GET file://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js net::ERR_FILE_NOT_FOUND local.html:18
【问题讨论】:
-
尝试检查
if互联网是否可以访问,然后加载远程文件。Else加载本地文件。这样,您可以将错误隔离到文件本身是否可以加载。 -
不知道怎么写查网的js,加载css动态。
标签: twitter-bootstrap twitter-bootstrap-3