擺渡人,外婆橋!
----只要路選對了,就不怕有多遠!
javascript在IE和Firefox中的區別1
1.調用appendChild方法增加input對象,設置type屬性的位置
1
<
html
>
2
<
head
>
3
<
title
>
test
</
title
>
4
<
script
language
="javascript"
>
5
function
test()
{
6
var
tbodyElement
=
document.getElementById(
"
tbody1
"
);
7
var
trElement
=
document.createElement(
"
tr
"
);
8
var
idTDElement
=
document.createElement(
"
td
"
);
9
10
idTDElement.innerHTML
=
1
;
11
var
nameTDElement
=
document.createElement(
"
td
"
);
12
13
var
inputElement
=
document.createElement(
"
input
"
);
14
nameTDElement.appendChild(inputElement);
15
inputElement.type
=
"
button
"
;
16
//
在IE中,這句話將會拋出異常,但在firefox能正常運行,如果type為text或者不設置type屬性,也都能正常運行
17
inputElement.value
=
"
Invoke
"
;
18
/**/
/*
19
修改成下面的語句就能正常運行:
20
var inputElement=document.createElement("input");
21
inputElement.type="button";
22
nameTDElement.appendChild(inputElement);
23
*/
24
25
tbodyElement.appendChild(trElement);
26
trElement.appendChild(idTDElement);
27
trElement.appendChild(nameTDElement);
28
}
29
</
script
>
30
</
head
>
31
<
body
>
32
<
input
type
="button"
value
="insert"
onclick
='test()'
>
33
<
table
cellpadding
="0"
cellspacing
="0"
border
="1"
>
34
<
tbody
id
='tbody1'
>
35
<
tr
>
36
<
td
width
="50"
>
ID
</
td
>
37
<
td
width
="200"
>
name
</
td
>
38
</
tr
>
39
</
tbody
>
40
</
table
>
41
</
body
>
42
</
html
>
2.appendChild一個radio對象,設置該對象的name屬性
1
var
nameTDElement
=
document.createElement(
"
td
"
);
2
var
radioElement
=
document.createElement(
"
input
"
);
3
radioElement.type
=
"
radio
"
;
4
nameTDElement.appendChild(inputElement);
5
radioElement.name
=
"
testRadioName
"
;
//
這句話在firefox是起作用的,但在IE下是不起作用的
6
/**/
/*
解決的辦法是
7
var radioElement=document.createElement("<input name='testRadioName'>");
8
radioElement.type="radio";
9
nameTDElement.appendChild(inputElement);
10
*/
3.對select控件增加和刪除Option
1
<
html
>
2
<
head
>
3
<
title
>
test
</
title
>
4
<
script
language
="javascript"
>
5
function
deleteRow()
{
6
var
selectElement
=
document.getElementById(
"
select1
"
);
7
selectElement.options.remove(
1
);
//
IE:OK Firefox:Failure
8
selectElement.remove(
1
);
//
IE:OK Firefox:OK
9
}
10
function
insertRow()
{
11
var
selectElement
=
document.getElementById(
"
select1
"
);
12
var
option
=
new
Option(
"
eeee
"
,
5
);
13
selectElement.add(option);
//
IE:OK Firefox:Failure
14
selectElement.options.add(option);
//
IE:OK Firefox:OK
15
}
16
</
script
>
17
</
head
>
18
<
body
>
19
<
input
type
="button"
value
="Delete"
onclick
='deleteRow()'
>
20
<
input
type
="button"
value
="Insert"
onclick
='insertRow()'
>
21
<
select
id
="select1"
>
22
<
option
value
="1"
>
aaa
</
option
>
23
<
option
value
="2"
>
bbb
</
option
>
24
<
option
value
="3"
>
ccc
</
option
>
25
<
option
value
="4"
>
ddd
</
option
>
26
</
select
>
27
</
body
>
28
</
html
>
發表于 2007-04-11 16:33
swingboat
閱讀(2314)
評論(6)
編輯
收藏
所屬分類:
javascript&DHTML&CSS
評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
為什么我看過你的“在struts1.1框架下,利用smartupload實現文件的上傳(可以是多個文件) ”文章后,做了Action 接受上傳文件不行呢?
edwin
評論于 2008-06-03 19:11
回復
更多評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
Action 如下:
public ActionForward loader(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LoadFileForm loadFileForm = (LoadFileForm) form;
ActionForward forward = null;
//實例化上載bean
SmartUpload mySmartUpload = new SmartUpload();
String suc =null;
ServletConfig config = getServlet().getServletConfig();
try {
//初始化
mySmartUpload.initialize(getServlet().getServletConfig(),request, response);
//上載文件
mySmartUpload.upload();
} catch (ServletException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
} catch (SmartUploadException e1) {
e1.printStackTrace();
}
//獲取除文件以外的相關信息,例如upload.jsp中隱藏控件id的值
String strId=(String)mySmartUpload.getRequest().getParameter("id");
suc= "ok!!";
//String cnt=(String)request.getParameter("id");
//獲得總的文件數
Files files=mySmartUpload.getFiles();
//int count = mySmartUpload.getFiles().getCount();
//轉換為視圖
Collection col=files.getCollection();
//遍歷輸出
Iterator it=col.iterator();
String filePath = null;
String path =null;
while(it.hasNext()){
File file=(File)it.next();
//得到文件名
String oldFileName=file.getFileName();
//得到沒后輟的文件名
String name = oldFileName.substring(0, oldFileName.lastIndexOf('.'));
//得到文件大小
int fileSize = file.getSize();
//得到后輟
String extname=file.getFileExt();
//得到文件保存路徑
filePath = request.getRealPath("/jsp");
//拼成完整的保存路徑名
path = filePath +"/" +name +"_" +fileSize +"." +extname;
//String fileName=Sequence.getSequence()+"."+extname;//產生一個唯一的文件名
try {
file.saveAs(path);
} catch (IOException e) {
e.printStackTrace();
} catch (SmartUploadException e) {
e.printStackTrace();
}
}
request.setAttribute("suc",response);
forward = mapping.findForward("success");
return forward;
}
edwin
評論于 2008-06-03 19:14
回復
更多評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
Jsp頁面如下:
<%@ page language="java" contentType="text/html;charset=gb2312"%>
<%@ taglib uri="
http://struts.apache.org/tags-bean"
prefix="bean"%>
<%@ taglib uri="
http://struts.apache.org/tags-html"
prefix="html"%>
<%@ taglib uri="
http://struts.apache.org/tags-logic"
prefix="logic"%>
<%@ taglib uri="
http://struts.apache.org/tags-tiles"
prefix="tiles"%>
<html>
<head>
<title>upload</title>
<style>
.lbtn {
font-family: verdana;
font-size: 10.5pt;
}
.ist {
font-family: verdana;
font-size: 14.8px;
size: 400
}
<!--
.STYLE2 {
font-size: 16px
}
.STYLE3 {
font-size: 36px;
font-weight: bold;
}
.STYLE4 {
color: #FFFFFF
}
body {
background-color: #99CCFF;
}
.STYLE9 {
font-size: 18px
}
-->
</style>
<script LANGUAGE="javascript">
function check(){
document.frm1.submit();
<!--document.body.innerHTML="Uploading Please wait!"; -->
}
var i=0;
function create(){
var sfrm = document.frm1.innerHTML;
var icnt = cnt.value;
for(j=0;j<icnt;j++)
{
sfrm = sfrm + "請選擇文件 "+i+" <input type=file name='file"+i+"' class=ist>";
sfrm = sfrm + " 路徑:<input type=text name='path"+i+"' value='' class=ist>";
sfrm = sfrm + "<br>";
i++;
}
document.frm1.innerHTML = sfrm;
document.frm1.cnt.value=i;
}
</script>
</head>
<body class=lbtn onload="document.frm1.cnt.value=cnt.value;">
<!-- 頁頭 -->
<jsp:include page="../../menu.jsp" />
<br>
<br>
<br>
<p align="center">
<span class="STYLE3">上 傳</span>
</p>
<logic:notEmpty name="suc">
<bean:write name="suc"/>
</logic:notEmpty>
<center>
請輸入要上傳文件的數量:
<input type=text name=cnt value="1" class=ist onchange="document.frm1.cnt.value=this.value;">
<input type=button name=bt1 value="生成上傳文件框" onclick="create();" class=lbtn>
<input type=button name=bt1 value="上傳" onclick="check();" class=lbtn>
<input type=button name=bt1 value="清除" onclick="document.location.reload();" class=lbtn>
<form name=frm1 method="post" encType="multipart/form-data" action="/dps_mj04/loadFile.do">
<input type=hidden name=cnt value="20" class=ist>
<input type = "hidden" name="status" value="loader">
<input type = "hidden" name="id" value="good">
</form>
<input type=button name=bt1 value="上傳" onclick="check();" class=lbtn>
<input type=button name=bt1 value="清除" onclick="document.location.reload();" class=lbtn>
</center>
</body>
</html>
edwin
評論于 2008-06-03 19:15
回復
更多評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
經過我的測試,問題是Action中:
//獲取除文件以外的相關信息,例如upload.jsp中隱藏控件id的值
String strId=(String)mySmartUpload.getRequest().getParameter("id");
//獲得總的文件數
Files files=mySmartUpload.getFiles();
得不到jsp頁中的數據。不知道為什么?jps
edwin
評論于 2008-06-03 19:21
回復
更多評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
jsp頁面可以正常找到Action中的方法,執行完后也可正常跳回本頁。
edwin
評論于 2008-06-03 19:23
回復
更多評論
#
re: javascript在IE和Firefox中的區別1[未登錄]
可以給我解答嗎?謝謝!!!
edwin
評論于 2008-06-03 19:25
回復
更多評論
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
IE對select的處理,又一怪現象:innerHTML竟然不起作用。
在IE下,頁面只有一個text的時候,回車將自動submit。
設置input的內容居中?
可惡的“本頁不但包含安全的內容,也包含不安全的內容。是否顯示不安全的內容”對話框?
HTML的特殊字符
javascript在IE和Firefox中的區別1
利用div進行頁面的布局2(position屬性)
利用div進行頁面的布局1(float&clear屬性)
javascript轉換日期字符串為Date對象
Table中table-layout:fixed樣式的作用。
<
2007年4月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
公告
導航
BlogJava
首頁
發新隨筆
發新文章
聯系
聚合
管理
統計
隨筆: 51
文章: 1
評論: 50
引用: 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(4)
給我留言
查看公開留言
查看私人留言
隨筆分類
JAVA(21)
(rss)
javascript&DHTML&CSS(15)
(rss)
Oracle/MySQL(6)
(rss)
SOA(1)
(rss)
WEB2.0(4)
(rss)
WorkFlow&BPEL(1)
(rss)
名詞概念(1)
(rss)
架構模式
(rss)
汽車&甲殼蟲
(rss)
設計模式(3)
(rss)
軟件工程(1)
(rss)
隨筆檔案
2007年9月 (1)
2007年8月 (3)
2007年7月 (1)
2007年5月 (2)
2007年4月 (4)
2007年3月 (1)
2007年2月 (1)
2006年12月 (1)
2006年11月 (2)
2006年10月 (1)
2006年8月 (1)
2006年4月 (1)
2006年3月 (2)
2006年2月 (4)
2005年12月 (26)
文章檔案
2006年1月 (1)
IT
竹筍炒肉
搜索
積分與排名
積分 - 132827
排名 - 466
最新隨筆
1.?IE對select的處理,又一怪現象:innerHTML竟然不起作用。
2.?在IE下,頁面只有一個text的時候,回車將自動submit。
3.?設置input的內容居中?
4.?可惡的“本頁不但包含安全的內容,也包含不安全的內容。是否顯示不安全的內容”對話框?
5.?利用JGroups同步兩臺server之間的cache。
6.?有關“+”和“_”的search。
7.?synchronized的作用
8.?HTML的特殊字符
9.?不同時區之間,時間的轉換?
10.?javascript在IE和Firefox中的區別1
最新評論
1.?re: javascript轉換日期字符串為Date對象
大牛
--sfafa
2.?re: synchronized的作用[未登錄]
把100換成1000就好了!
--xyz
3.?re: synchronized的作用
晦澀難懂!
--無知者
4.?re: synchronized的作用
好
--白河夜歌
5.?re: 可惡的“本頁不但包含安全的內容,也包含不安全的內容。是否顯示不安全的內容”對話框?
評論內容較長,點擊標題查看
--老梁
閱讀排行榜
1.?javascript轉換日期字符串為Date對象(47709)
2.?synchronized的作用(16397)
3.?可惡的“本頁不但包含安全的內容,也包含不安全的內容。是否顯示不安全的內容”對話框?(11083)
4.?不同時區之間,時間的轉換?(7445)
5.?利用JGroups同步兩臺server之間的cache。(6601)
評論排行榜
1.?synchronized的作用(18)
2.?可惡的“本頁不但包含安全的內容,也包含不安全的內容。是否顯示不安全的內容”對話框?(7)
3.?javascript在IE和Firefox中的區別1(6)
4.?javascript轉換日期字符串為Date對象(4)
5.?在IE下,頁面只有一個text的時候,回車將自動submit。(3)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 swingboat
主站蜘蛛池模板:
亚洲AV无码1区2区久久
|
亚洲另类春色国产精品
|
久久亚洲免费视频
|
亚洲一级片在线观看
|
亚洲AV成人精品日韩一区18p
|
羞羞视频免费网站在线看
|
中文字幕亚洲色图
|
四虎影在线永久免费观看
|
四虎国产精品免费永久在线
|
亚洲嫩草影院在线观看
|
波多野结衣免费视频观看
|
久久精品乱子伦免费
|
大桥未久亚洲无av码在线
|
亚洲av综合色区
|
波多野结衣视频在线免费观看
|
99精品视频在线视频免费观看
|
在线观看亚洲电影
|
亚洲最新视频在线观看
|
亚洲av日韩av欧v在线天堂
|
91短视频在线免费观看
|
深夜免费在线视频
|
日韩亚洲国产综合高清
|
亚洲AV无码成人网站久久精品大
|
国产午夜鲁丝片AV无码免费
|
99爱视频99爱在线观看免费
|
www永久免费视频
|
亚洲欧美日韩中文字幕一区二区三区
|
亚洲韩国—中文字幕
|
国产免费变态视频网址网站
|
中文字幕天天躁日日躁狠狠躁免费
|
日日狠狠久久偷偷色综合免费
|
亚洲jjzzjjzz在线观看
|
亚洲AV午夜福利精品一区二区
|
四虎免费影院4hu永久免费
|
国产又大又粗又长免费视频
|
A片在线免费观看
|
人人爽人人爽人人片av免费
|
亚洲精品无码久久久久APP
|
亚洲国产成人精品无码一区二区
|
国产特黄一级一片免费
|
色五月五月丁香亚洲综合网
|