MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2025-08-07, 22:52

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 4 篇文章 ] 
發表人 內容
文章發表於 : 2005-05-26, 19:13 
離線

註冊時間: 2005-05-26, 18:51
文章: 2
請問一下以下的html code有什麼問題嗎?
在IE下很正常,
但在Firefox裏第二行的document.write好像就不能運作了
而且一直顯示"載入中",好像在什麼地方卡住了..
原始碼如下:
------------------
<html>
<head>
<title> new document </title>
<script type="text/javascript">
<!--
var tmp = new Array(2);
tmp[0] = new Array(2);
tmp[0][0] = "lalala";
tmp[0][1] = "hahaha";

function test(){
document.write(tmp[0][0]);
document.write(tmp[0][1]);
}
//-->
</script>
</head>
<body>
<input type="button" value="test" onclick="javascript:test();">
</body>
</html>


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2005-05-26, 19:20 
離線
[MozTW 版主群]
頭像

註冊時間: 2003-09-15, 03:47
文章: 1016
來自: Taiwan
document.write 表示你要重寫整個頁面,所以第一個指令執行後,整個頁面已予清除,第二個指令也就不見了

另外,JS 語法也不正確,應該是
document.open();
document.write(...);
:
document.close();

如果不要清除網頁,可用:
text = document.createTextNode("blah blah blah");
document.body.appendChild(text);


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2005-05-26, 20:18 
更新後html code,可以執行了,感謝 :lol:
--------------------------------------
<html>
<head>
<title> new document </title>
<script type="text/javascript">
<!--
var tmp = new Array(2);
tmp[0] = new Array(2);
tmp[0][0] = "lalala";
tmp[0][1] = "hahaha";

function test(tmp2){
document.open();
document.write("lalala");
document.write("hahaha");
document.close();
}
//-->
</script>
</head>
<body>&nbsp;
<input type="button" value="test" onclick="javascript:test(tmp);">
</body>
</html>


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
  
引用回覆  
 文章主題 :
文章發表於 : 2005-05-26, 20:22 
離線

註冊時間: 2005-05-26, 18:51
文章: 2
上一篇寫錯.,用guest不能修改...:cry:,更正如下..
--------------------------
<html>
<head>
<title> new document </title>
<script type="text/javascript">
<!--
var tmp = new Array(2);
tmp[0] = new Array(2);
tmp[0][0] = "lalala";
tmp[0][1] = "hahaha";

function test(tmp2){
document.open();
document.write(tmp2[0][0]);
document.write(tmp2[0][1]);
document.close();
}
//-->
</script>
</head>
<body>
<input type="button" value="test" onclick="javascript:test(tmp);">
</body>
</html>


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 4 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
cron
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群