简体   繁体   English

javascript在IE中并非始终有效

[英]javascript doesn't work all the time in IE

Using spring form tags in jsp. 在jsp中使用spring表单标签。

Following is my script,which i am using for pagination : 以下是我用于分页的脚本:

function getNextPage(){
var next = document.getElementById('nextPageID');
next.checked=true;
var buttonName = document.getElementById('refreshbuttonID');
buttonName.click();
}

when user clicks Next in view (using jsp), onclick event I am calling the getNextPage(); 当用户单击视图中的Next (使用jsp)时, onclick事件我正在调用getNextPage();

<button type="submit" onclick="getNextPage();">Next</button>

and I set hidden check-box to true 我将隐藏复选框设置为true

<td>
     <form:checkbox id="nextPageID" path="nextPage"/>  
     <input type="hidden" value="1" name="_nextPage"/>
</td>

and then calling the method in controller to get next results and show on page. 然后在控制器中调用方法以获取下一个结果并显示在页面上。

everything works fines in chrome and firefox, when it comes IE, some times it does and sometimes doesn't. IE和IE浏览器在chrome和firefox中都可以正常工作,有时可以,有时不能。 and page keeps refreshing with old data..It works all the time in debug mode (even in IE) 和页面会不断刷新旧数据。它始终在调试模式下运行(即使在IE中也是如此)

It is not hitting the javascript in IE on some occassions . It is not hitting the javascript in IE on some occassions is there something I am missing in function or something different to do in IE? 有什么我在功能上缺少的东西或在IE中要做的其他事情吗? Any suggestions! 有什么建议么!

I'm going to make a guess based on the limited information given: change your button to use type="button" : 我将根据给定的有限信息做出一个猜测:将您的按钮更改为使用type="button"

<button type="button" onclick="getNextPage();">Next</button>

...because if you have a submit button in a form and you don't cancel the default behaviour (which your code doesn't) it will try to submit the form in addition to whatever your code is doing. ...因为如果您在表单中有一个提交按钮,并且您没有取消默认行为(您的代码没有这样做),那么除了您的代码在做什么之外,它还会尝试提交表单。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM