简体   繁体   中英

javascript doesn't work all the time in IE

Using spring form tags in jsp.

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();

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

and I set hidden check-box to 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. and page keeps refreshing with old data..It works all the time in debug mode (even in IE)

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? Any suggestions!

I'm going to make a guess based on the limited information given: change your button to use 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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