【发布时间】:2013-12-31 00:01:30
【问题描述】:
在所有浏览器上:资源解释为脚本,但使用 MIME 类型 text/plain:"file:///E:/Projetions%20Matcher/Canvas/jquery.min.js" 传输。
所以 jquery.min.js 已加载,但 livello.js 未加载。为什么?
编辑:我试图将它加载到服务器上,但出现了同样的错误
HTML: ....
<script src="jquery.min.js" type="text/javascript"></script>
<script src="livello.js" type="text/javascript"></script>
....
liveello.js:
var c=document.getElementById("app");
var ctx=c.getContext("2d");
function resize(){
c.style.width = window.innerWidth + 'px';
c.style.height = window.innerHeight + 'px';
var gameWidth = window.innerWidth;
var gameHeight = window.innerHeight;
var scaleToFitX = gameWidth / c.width;
var scaleToFitY = gameHeight / c.height;
var currentScreenRatio = gameWidth / gameHeight;
var optimalRatio = Math.min(scaleToFitX, scaleToFitY);
c.style.width = c.width * optimalRatio + "px";
c.style.height = c.height * optimalRatio + "px";
}
window.onresize=function(){resize();};
function clean()
{c.width=window.innerWidth;
c.height=window.innerHeight;}
clean();
【问题讨论】:
-
另外,您应该真正安装服务器,而不是直接从文件系统打开文件。
-
@Juhana: 1) 不,因为我在 file:/// 而不是服务器中 2) 但是为什么 jquery 也可以在本地工作?
-
到底是什么问题? “资源被解释为脚本但是......”不是错误,而是一个通知。它不会导致脚本无法运行。
-
正是我想知道的!为什么 livello.js 不工作(但 jquery.min.js 工作)?
标签: javascript jquery html google-chrome