开发者

how to avoid the page reload while using javascript

I am using javascript in a jsp page to make some changes [adding a row in the table] to the current HTML page. The addition is happening successfully, but when i am about to exit from the function the page is getting reloaded.

开发者_高级运维

How to avoid the page reloading and, show the page without any change in the scroll.


Add return false at the end of the function if it's an event handler.

I've seen people usually recommend event.preventDefault() but I've personally had it fail on some browsers for me. So not quite sure if that will work just as well.


This is a bit vague, we don't know exactly what you are trying to do. However, I think it's better to use jQuery. Or AJAX. Learn jQuery and try to implement your code in jQuery, it's easy, efficient.

jQuery tutorial: http://www.w3schools.com/jquery/default.asp and AJAX tutorial: http://www.w3schools.com/ajax/default.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜