1
我想創建一個加載外部JS文件,觀察Jquery如何加載的HTML頁面,我想我只需要將JavaScript加載到腳本標記中,但是它一直在做絕對沒有。HTML加載一個空的JS文件
我的HTML:
<html>
<head>
<title>Pagina senza titolo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="Generate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
generate(1);
}
</script>
</head>
<body>
<form id="form1">
<div id = "Top" style = "text-align:left">
</div>
<div id = "UI" style = "float: left; width: 400px; height: 200px;">
</div>
</form>
</body>
</html>
,這是外部的js文件Generate.js:
function Generate(num) {
var roomType = Math.floor((Math.random() * 20) + 1);
var vertOriz = Math.floor((Math.random() * 2) + 1);
var i, j, x, y;
if (roomType <= 10) {
i = 10;
j = 10;
}else
if (roomType > 10 && roomType <= 18) {
if (vertOriz == 1) {
i = 10;
j = 20;
} else {
i = 20;
j = 10;
}
}else
if (roomType > 18) {
i = 20;
j = 20;
}
$("#UI").append("<table id = 'Room" + num + "'></table>");
for (y = 0; y < i; y++) {
$("#Room" + num).append("<tr id = y" + y + "></tr>");
for (x = 0; x < j; x++) {
if(y == 0){
if(x == 0){
$("#y" + y).append("<td id = x" + x + ">┏</td>");
}else
if(x == (j - 1)){
$("#y" + y).append("<td id = x" + x + ">┓</td>");
}else{
$("#y" + y).append("<td id = x" + x + ">━</td>");
}
}else
if (y == (i - 1)) {
if (x == 0) {
$("#y" + y).append("<td id = x" + x + ">┗</td>");
} else
if (x == (j - 1)) {
$("#y" + y).append("<td id = x" + x + ">┛</td>");
} else {
$("#y" + y).append("<td id = x" + x + ">━</td>");
}
} else
if (y > 0 && y < (i - 1)) {
if (x == 0 || x == (j - 1)) {
$("#y" + y).append("<td id = x" + x + ">┃</td>");
} else {
$("#y" + y).append("<td id = x" + x + "> </td>");
}
}
}
}
}
怎麼可能是什麼問題?我試圖在IE上運行它
「**簡單的印刷錯誤**」..標記。 – fzzle
...我怎麼錯過了... – Malignus