jsp页面上不兼容部分的代码:
<div id='divfile' style="background-color: white;display: none;">
<table style="WIDTH: 90%;">
<tr>
<%
String excelPath = "";
if("6200".equals(sapno)) 
{
    excelPath="salesforecastitaly/";
}else if("6280".equals(sapno)) 
{
    excelPath="salesforecastgerman/";
}
else if("6300".equals(sapno))
{
    excelPath="salesforecastusa/";
}
else
{
    excelPath="salesforecast/";
}
%>
<td style="text-align: center">
<input type="button" icon='icon-excel' value="&nbsp;&nbsp;<bean:message key='label.downloadtemplate' />" onclick="javascript:document.location='<%=request.getContextPath()%>/console/pages/common/download.jsp?filename=<bean:message key='label.templatename' />_<%=pcycle %>.xlsx&filedir=/console/pages/basedata/<%=excelPath %>'"></input> 
&nbsp;&nbsp;<input type="button" value="&nbsp;&nbsp;<bean:message key='label.commit' />" icon='icon-submit' onclick="importExcel();"></input> 
</td>
</tr>
<tr>
<td style="text-align: center" >
<input type="text" id="fakefile" name="fakefile" size="60" readOnly> <input type="button"  icon='icon-folder_open'  onclick="choosefile();" value="&nbsp;&nbsp;<bean:message key='label.choosefile' />">  
</td>
</tr>
<tr>
<td id="statustd" style="text-align: center" >&nbsp;
</td>
</tr>
</table>
</div>
<iframe name="upfileframe" id="upfileframe" width="0" height="0" src="<%=request.getContextPath()%>/console/pages/basedata/salesforecast/uploadImport.jsp" onload ="iframeload = true;"></iframe>
其中是一个div包含了一个table,table里有下载模板(label.downloadtemplate),提交(label.commit)以及一个文件选择功能。
当前问题是在我载入该jsp文件时firefox会自动运行下载模板功能。以及提交功能。
下面是相应的一些列的js方法
/* 导入 */
function onImport()
{
alert("000");
if(!checkAddImportDel())
{
alert("Sales forecast can only be uploaded from Monday to Wednesday.");
return;
}
var startDate = document.getElementById("startDate").value;
if(startDate=="")
{
alert("Forecast Date is mandatory.");
return;
}

$('#divfile').modal({"autoResize":true,
"onClose":function(){ 
if(document.frames("upfileframe").document.all.retcode.value == 'S'){
alert("123");
document.EAPForm.pageNo.value="1";
document.EAPForm.action=unieap.WEB_APP_NAME+"/salesForecast.do?method=getList";
document.EAPForm.submit();
}else{
alert("456");
this.close();
document.EAPForm.pageNo.value="1";
document.EAPForm.action=unieap.WEB_APP_NAME+"/salesForecast.do?method=getList";
document.EAPForm.submit();
}
 }
 });
}

/* 导入提交 */
function importExcel()
{
alert("submit")
var file = $("#fakefile").val();
if(file == "")
{
retmsg("Pls choose the file");
return;
}
    var suffix = file.substring(file.lastIndexOf('.')+1,file.length);
    if(suffix != 'xls' && suffix != 'XLS' && suffix!='xlsx')
    {
retmsg("Pls choose xls file or xlsx file");
return;
    }
    $("#statustd").html("<img src='"+unieap.WEB_APP_NAME+"/console/images/ico/loading_ani.gif'></img>");
document.frames("upfileframe").OnSubmit();
}

 /*选择文件*/
function choosefile()
{
if(!iframeload) return;
document.frames("upfileframe").document.EAPForm.importfile.click();


/* 错误反馈 */
function retmsg(msg)
{
if(!msg)
msg = document.frames("upfileframe").document.all.retmsg.value;
$("#statustd").html("<font color=red><b>" + msg + "</b></font>");
}
请各位大牛帮帮忙~~~~~Firefox浏览器不兼容

解决方案 »

  1.   

    document.frames("upfileframe")
    你不兼容的只是这部分吧如果你只是一个iframe,那么直接用window.frames[0]酒可以兼容了,也可以加一个id,使用document.getElementByIdx("ifrm")
      

  2.   

    我改了。还是不好用啊。另外onclick="javascript:document.location='<%=request.getContextPath()%>/console/pages/common/download.jsp?filename=<bean:message key='label.templatename' />_<%=pcycle %>.xlsx&filedir=/console/pages/basedata/<%=excelPath %>'"onclick="importExcel();这个两个方法居然在加载改jsp页面的时候就触发了。。令我很是不理解啊。