2014-07-19 46 views

回答

0

您可以將修復如下面的代碼:

$(document).ready(function() { 
    var position_Y_before = null; 

    $(".handsontable").handsontable({ 
     //some code here for initializing the table and its functions 

     //Then I added this callback function 
     beforeKeyDown: function(e) { 
      position_Y_before = window.pageYOffset || 0; 
     }; 

    }); 

    //Here we prevent from scrolling to top of page after pasting to handsontable with cmd+v or ctrl+v 
    $(window).scroll(function(){ 
     if(position_Y_before != null){ 
      window.scrollTo(0, position_Y_before); 
      position_Y_before = null; 
     } 
    }); 

}); 

這對我的作品,至少,希望它可以幫助你的!