取消按钮在Firefox和Chrome中的行为有所不同

时间:2014-02-26 06:34:11

标签: javascript jsp google-chrome firefox

注意:几小时后,我也在Javaranch中发布了这个问题。其链接为http://www.coderanch.com/t/629456/JSP/java/Cancel-button-behaves-differently-Chrome。 我还没有收到回复。我在这里张贴它,看看我是否可以得到一两个建议。在struts和JSP方面我也是初学者所以请告诉我是否应该提供更多详细信息。

问题是我的网页上的取消按钮在chrome和firefox浏览器中表现不同。

我当前的网址是     context path / importEmployee.do?method = load。

在我当前的页面中,我上传了一个CSV文件。这个页面有两个按钮 - 确定和取消,这些按钮是我遇到的麻烦(我会在短时间内到达那个部分)。相关的JSP部分如下。

<html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data">    
....... some headers and title bar and stuff... and then as follows.  
<div class="contentSection">  
    <table border="0"   class="formTable">  
        <html:hidden property = "selectedSet" />   
        <tr>  
            <td class="formLabel"><label for="file">Download File:</label>  
            </td>  
            <td>  
                <span>   
                    <a class="buttonStyle"  rel="nofollow">Download Sample CSV</a>                                
                </span>   
            </td>  
        <tr>  
            <td  class="spacerCell"> </td>  
        </tr>  
        <tr>    
            <td class="formLabel"><label for="file">CSV File:</label></td>  
            <td><html:file property="importFile" styleId="importFile" size="60" maxlength="120" /></td>  
        </tr>  
        <tr>  
            <td  class="spacerCell"> </td>  
        </tr>  
    </table>  
</div>   
<table   border="0" class="footerBar">  
    <tr>  
        <td id="footerLeft">                      
            <html:submit value="  OK  " title="  OK  " styleClass="button">  
            </html:submit>      
            <span>   
                <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> Cancel </a>                               
            </span>                  
        </td>  
        <td id="footerRight" class="pagination">    
        </td>  
    </tr>  
</table>

上传CSV文件并单击确定后,将调用相应的操作类方法,并且我的网址将更改为 -         context path / importEmployee.do?method = save

此页面基本上包含导入统计信息,未处理记录的错误消息等。 此页面还有一个确定和取消按钮。 相应的JSP部分如下。

<html:form action="importEmployee?method=save" method="POST" styleId="importEmployee" enctype="multipart/form-data">  
    <table border="0"  >  
      <tr>  
        <td id="leftEdge"><img src="<%= request.getContextPath()%>/images/new/edge_left.gif" width="30"
     

height =“321”alt =“”/&gt;
                

        ..... some processing and then...  

        <table   border="0" class="footerBar">  
            <tr>  
                <td id="footerLeft">       
                    <span>   
                        <a class="buttonStyle" href="<%=request.getContextPath()%>/employees.do?method=load"> OK </a>

                    </span>  
                    <input name="cancel" id="cancel" type="submit" class="button" value="Cancel" onclick="goBack(); return false;" />    
                </td>  
                <td id="footerRight" class="pagination">    
                </td>  
            </tr>  
      </table>

所以,如果我点击第二页中的cancel(context path / importEmployee.do?method = save),我会回到第一个URL页面,即 context path / importEmployee.do?method = load。 但是这部分在Firefox和Chrome浏览器中表现不同。 在Chrome中,如果我在第二页中单击“取消”,我仍然可以在第一页中看到上传的文件名(第一个JSP中的隐藏属性是文件名)。如果我点击确定,我可以再次进行处理,就像在第一页上第一次点击确定一样。 但是,当我在Firefox浏览器中运行我的应用程序时,如果我在第二页中单击“取消”,则上传的文件名在第一页中显示“未选择文件”。因此,要再次导入Employees,我需要再次上传新的/相同的CSV文件。

即使我在Chrome中运行我的应用程序,当我在第二页中单击“取消”时,我也不希望该文件出现在第一页中。是的,我要求文件名是隐藏属性。这是因为根据文件中的数据,会进行不同类型的处理,其中一些需要在另一页上从用户那里获取额外的输入,第三页需要进行处理。因此,文件名应该传递给表单,但我不希望用户再次上传文件。

但是,如果用户点击取消,我不希望文件名保留在第一页中。但这不会发生。

所以我有两个问题。为什么Chrome和Firefox中的行为有所不同,有没有办法可以纠正它在Chrome中的行为方式?

1 个答案:

答案 0 :(得分:0)

这已经解决了。

工作人员表示,此取消按钮行为是一种已知行为。在chrome中单击取消后再次查看文件名是可以的。我们不应该在Mozilla中看到它。

对于我的疑问感到困惑和感谢。

相关问题