浏览器兼容模式跟快速模式下运行HTML差异
浏览器兼容模式和快速模式下运行HTML差异
以下文件在浏览器兼容模式下点击“添加”,“删除”按钮能够很好地添加或删除一行,
但是在快速模式下,点击“添加”或“删除”后就好像自动点击了“文件上传”按钮。
为何这样,无法理解,求助于各位大侠解惑。
<html>
<head >
<title>FileUpLoad</title>
</head>
<script language="javascript">
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all)
foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById)
foundObj = document.getElementById(theObj);
return foundObj;
}
function delRow()
{
var bt_filesum = findObj("bt_filesum",document);
var filesum = parseInt(bt_filesum.value);
if (filesum<=1)
{
alert('上传文件数最小为1,删除无效');
}
else
{
var signFrame = findObj("SignFrame",document);
signFrame.deleteRow(filesum-1);
bt_filesum.value = (filesum-1).toString() ;
}
}
function addRow()
{
var bt_filesum = findObj("bt_filesum",document);
var filesum = parseInt(bt_filesum.value)+1;
if(filesum>5)
{
alert('一次最多上传5个文件');
}
else
{
var signFrame = findObj("SignFrame",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "file_addordel" + filesum; //新行之id属性赋值
//添加列0:上传文件
var newTD0=newTR.insertCell(0);
newTD0.align="right"; //列0属性之align
newTD0.innerHTML = "<input type='hidden' name='MAX_FILE_SIZE' value='5000000'/>上传文件"+filesum+":";
//添加列:上传文件输入格
var newTD1=newTR.insertCell(1);
newTD1.innerHTML = "<input type='file' name='file_upload[]' id='file_upload[]'/>"
//添加列:文件版本
var newTD2=newTR.insertCell(2);
newTD2.align="right";
newTD2.innerHTML ="文件版本:";
//添加列:文件版本输入
var newTD3=newTR.insertCell(3);
newTD3.innerHTML ="<input type='text' name='file_ver' value='100'size='8' maxlength='15'/>";
bt_filesum.value = (filesum).toString() ;
}
}
</script>
<body>
<p>
<form action='File_upload_2.php' method="post" enctype="multipart/form-data">
<table width="100%" border="0">
<tr>
<td colspan="4"><hr style="FILTER:alpha(opacity=100,finishopacity=0,style=2)" width="100%" color=#987cb9 size=3></td>
</tr>
</table>
<table width="100%" border="0" id="SignFrame">
<tr id="file_addordel1">
<td width="20%"align="right"><input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>上传文件1:</td>
<td width="30%"><input type="file" name="file_upload[]" id="file_upload[]"/></td>
<td width="12%"align="right">文件版本:</td>
<td width="20%"><input type="text" name="file_ver[]" value="100"size="8" maxlength="15"/></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td width="20%"><br/></td>
<td width="10%"><br/></td>
<td width="10%"><br/></td>
<td width="40%"><br/></td>
<td width="20%"><br/></td>
</tr>
<tr>
<td colspan="5"><hr style="FILTER:alpha(opacity=100,finishopacity=0,style=3)" width="100%" color=#987cb9 size=3></td>
</tr>
<tr>
<td><br/></td>
<td align="center"> <button id="file_addROW" value="file_addROW"onclick="addRow()"> 添加 </button></td>
<td align="center"> <button id="file_delROW" value="file_delROW"onclick="delRow()"> 删除 </button></td>
<td align="center"><input type="submit" id="bt_uploadfile" name="bt_uploadfile" value="文件上传"/></td>
<td><input type="hidden" id="bt_filesum" value="1"></td>
</tr>
</table>
</p>
</body>
</html>
以下文件在浏览器兼容模式下点击“添加”,“删除”按钮能够很好地添加或删除一行,
但是在快速模式下,点击“添加”或“删除”后就好像自动点击了“文件上传”按钮。
为何这样,无法理解,求助于各位大侠解惑。
<html>
<head >
<title>FileUpLoad</title>
</head>
<script language="javascript">
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all)
foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById)
foundObj = document.getElementById(theObj);
return foundObj;
}
function delRow()
{
var bt_filesum = findObj("bt_filesum",document);
var filesum = parseInt(bt_filesum.value);
if (filesum<=1)
{
alert('上传文件数最小为1,删除无效');
}
else
{
var signFrame = findObj("SignFrame",document);
signFrame.deleteRow(filesum-1);
bt_filesum.value = (filesum-1).toString() ;
}
}
function addRow()
{
var bt_filesum = findObj("bt_filesum",document);
var filesum = parseInt(bt_filesum.value)+1;
if(filesum>5)
{
alert('一次最多上传5个文件');
}
else
{
var signFrame = findObj("SignFrame",document);
//添加行
var newTR = signFrame.insertRow(signFrame.rows.length);
newTR.id = "file_addordel" + filesum; //新行之id属性赋值
//添加列0:上传文件
var newTD0=newTR.insertCell(0);
newTD0.align="right"; //列0属性之align
newTD0.innerHTML = "<input type='hidden' name='MAX_FILE_SIZE' value='5000000'/>上传文件"+filesum+":";
//添加列:上传文件输入格
var newTD1=newTR.insertCell(1);
newTD1.innerHTML = "<input type='file' name='file_upload[]' id='file_upload[]'/>"
//添加列:文件版本
var newTD2=newTR.insertCell(2);
newTD2.align="right";
newTD2.innerHTML ="文件版本:";
//添加列:文件版本输入
var newTD3=newTR.insertCell(3);
newTD3.innerHTML ="<input type='text' name='file_ver' value='100'size='8' maxlength='15'/>";
bt_filesum.value = (filesum).toString() ;
}
}
</script>
<body>
<p>
<form action='File_upload_2.php' method="post" enctype="multipart/form-data">
<table width="100%" border="0">
<tr>
<td colspan="4"><hr style="FILTER:alpha(opacity=100,finishopacity=0,style=2)" width="100%" color=#987cb9 size=3></td>
</tr>
</table>
<table width="100%" border="0" id="SignFrame">
<tr id="file_addordel1">
<td width="20%"align="right"><input type="hidden" name="MAX_FILE_SIZE" value="5000000"/>上传文件1:</td>
<td width="30%"><input type="file" name="file_upload[]" id="file_upload[]"/></td>
<td width="12%"align="right">文件版本:</td>
<td width="20%"><input type="text" name="file_ver[]" value="100"size="8" maxlength="15"/></td>
</tr>
</table>
<table width="100%" border="0">
<tr>
<td width="20%"><br/></td>
<td width="10%"><br/></td>
<td width="10%"><br/></td>
<td width="40%"><br/></td>
<td width="20%"><br/></td>
</tr>
<tr>
<td colspan="5"><hr style="FILTER:alpha(opacity=100,finishopacity=0,style=3)" width="100%" color=#987cb9 size=3></td>
</tr>
<tr>
<td><br/></td>
<td align="center"> <button id="file_addROW" value="file_addROW"onclick="addRow()"> 添加 </button></td>
<td align="center"> <button id="file_delROW" value="file_delROW"onclick="delRow()"> 删除 </button></td>
<td align="center"><input type="submit" id="bt_uploadfile" name="bt_uploadfile" value="文件上传"/></td>
<td><input type="hidden" id="bt_filesum" value="1"></td>
</tr>
</table>
</p>
</body>
</html>