简体   繁体   English

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

[英]Cancel button behaves differently in Firefox and in Chrome

Note : A few hours back, I had posted this question in Javaranch also. 注意:几个小时后,我也在Javaranch中发布了这个问题。 The link for that is http://www.coderanch.com/t/629456/JSP/java/Cancel-button-behaves-differently-Chrome . 相应的链接是http://www.coderanch.com/t/629456/JSP/java/Cancel-button-behaves-differently-Chrome I haven't received a response yet. 我还没有收到回复。 I'm posting it here to see if I could get a suggestion or two. 我将其张贴在这里,看看是否能得到一两个建议。 Also I am very beginner when it comes to struts and JSPs so please let me know if I should provide more details. 另外,我在Struts和JSP方面还是一个初学者,所以请告知我是否应该提供更多详细信息。

The problem is the cancel button on my web page behaves differently in chrome and in firefox browsers. 问题是我的网页上的“取消”按钮在chrome浏览器和Firefox浏览器中的行为不同。

My current URL is context path/importEmployee.do?method=load. 我当前的URL是context path / importEmployee.do?method = load。

In my current page, I upload a CSV file. 在当前页面中,我上传了一个CSV文件。 This page has two buttons-- ok and Cancel and these buttons are what I'm having trouble with ( I will come to that part in a short while). 该页面有两个按钮-确定和取消,而这些按钮正是我遇到的麻烦(稍后我会介绍该部分)。 The relevant JSP part is as follows. 相关的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> 

Once I upload the CSV file and click on ok, the appropriate action class method is invoked and my url changes to - context path/importEmployee.do?method=save 上传CSV文件并单击“确定”后,将调用适当的操作类方法,并且我的url更改为-context path / importEmployee.do?method = save

This page basically contains the import statistics, error messages for unprocessed records and such things. 该页面基本上包含导入统计信息,未处理记录的错误消息等。 This page also has an ok and a cancel button. 该页面还具有确定和取消按钮。 The corresponding JSP parts are as follows. 相应的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="" /> height =“ 321” alt =“” />

  ..... 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> 

So, if I click on cancel in the second page (context path/importEmployee.do?method=save), I go back to the first URLpage, ie to context path/importEmployee.do?method=load. 因此,如果单击第二页中的“取消”(上下文路径/importEmployee.do?method=save),则会返回到第一个URL页面,即上下文路径/importEmployee.do?method=load。 But this part behaves differently in Firefox and in Chrome browsers. 但是此部分在Firefox和Chrome浏览器中的行为有所不同。 In Chrome, if I click on cancel in the second page, I can still see the uploaded file name( the hidden property in the first JSP is the file name ) in the first page. 在Chrome中,如果我在第二页中单击“取消”,则仍然可以在第一页中看到上载的文件名(第一个JSP中的隐藏属性是文件名)。 And if I click on ok, I can do the processing again as was done by clicking ok the first time on the first page. 如果单击“确定”,则可以再次进行处理,就像在第一页上单击“确定”一样。 However when I run my application in a Firefox browser, if I click on cancel in the second page, the uploaded file name says 'no file selected' in the first page. 但是,当我在Firefox浏览器中运行应用程序时,如果在第二页中单击“取消”,则上载的文件名在第一页中显示“未选择文件”。 Hence to import Employees again, I need to upload a new/same CSV file again. 因此,要再次导入员工,我需要再次上传新的/相同的CSV文件。

I don't want the file to be present in the first page when I click on cancel in the second page even when I run my application in Chrome. 即使我在Chrome中运行应用程序,我也不想在第二页中单击“取消”时在第一页中显示该文件。 Yes, I require the file name to be a hidden property. 是的,我要求文件名是隐藏属性。 This is because depending on the data in the file, different kind of processings are done and some of them require to take additional inputs from user on another page and a third page does the processing. 这是因为取决于文件中的数据,将执行不同类型的处理,并且其中一些处理需要在另一页上接受用户的其他输入,而第三页进行处理。 So the file name should be passed on to the form but I don't want the user to upload the file again. 因此,文件名应传递给表单,但我不希望用户再次上传文件。

However in the event the user clicks on cancel, I don't want the file name to be retained in the first page. 但是,如果用户单击“取消”,则我不希望文件名保留在第一页中。 But this isn't happening. 但是,这没有发生。

So I have two questions. 所以我有两个问题。 Why is the behaviour different in Chrome and in Firefox and is there a way I can correct the way it behaves in chrome? 为什么Chrome和Firefox中的行为有所不同,有什么办法可以纠正它在chrome中的行为?

This is resolved. 解决了。

Folks at work said that this cancel button behaviour is a known behaviour. 工作中的人们说,取消按钮的行为是一种已知的行为。 Seeing the file name again after clicking cancel in chrome is ok. 单击Chrome中的“取消”后,再次看到文件名是可以的。 We shouldn't see it in Mozilla. 我们不应该在Mozilla中看到它。

Sorry for the confusion and thanks for going through my question. 很抱歉造成您的困惑,也感谢您回答我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 按钮在Chrome和Firefox上的行为有所不同 - Button behaves differently on Chrome and Firefox "setPointerCapture 在 Chrome 和 Firefox 中的行为不同" - setPointerCapture behaves differently in Chrome and Firefox setInterval()在Firefox和Chrome中的行为有所不同 - setInterval() behaves differently in Firefox and Chrome iframe 主体上的 ResizeObserver 在 Chrome 和 Firefox 上的行为不同 - ResizeObserver on iframe body behaves differently on Chrome and Firefox 在Flexbox中固定的位置在Chrome和Safari / Firefox之间的行为有所不同 - Position fixed in Flexbox behaves differently between chrome and safari / firefox 在iFrame中单击锚点在Firefox和Chrome中的行为有所不同 - Clicking an anchor inside an iFrame behaves differently in Firefox and Chrome 为什么document.write()在Firefox和chrome中表现不同? - Why document.write() behaves differently in Firefox and chrome? Javascript动画在更新的Chrome中的行为有所不同 - Javascript animation behaves differently in updated Chrome JavaScript替换在Chrome和IE中的行为有所不同 - JavaScript replace behaves differently in Chrome to IE Javascript日期构造函数在IE和Chrome中的行为有所不同 - Javascript Date constructor behaves differently in IE and Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM