Click here to Skip to main content
15,888,008 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using this function to scroll down the page by clicking keyboard down key and when page is scroll down i am calling one more function to load data, this is working fine but problem is when i close the page i am getting object object dialog box please help.

NOTE: How many times i click on the page so many times object object dialog box will appear.

window.onkeydown = keydown;
       function keydown() {
           window.scrollBy(0, 10);
          if ($(window).scrollTop() == $(document).height() - $(window).height()) {
          CallWebService();
          }
       }
Posted
Updated 13-Jun-14 19:08pm
v2

1 solution

You should modify your code, in the way that only when you press some keys (like Up and Down) your scrolling part, like in the next example:
C#
window.onkeydown = keydown;
    function keydown(evt) {
       if (evt != undefined && (evt.keyCode == 38 || evt.keyCode== 40) //Up or Down key
       {
           window.scrollBy(0, 10);
          if ($(window).scrollTop() == $(document).height() - $(window).height()) {
          CallWebService();
          }
        }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900