how to control page scrollbar position
656413Apr 29 2010 — edited Apr 30 2010I have a APEX page. The main contents of the page is a HTML region of type PL/SQL (anonymous block). In other words, the region is generated by using PL/SQl procedure. There is a html table which I allow user to insert/delete rows.
I got a problem with the scroll bar. The requirement is that: After inserted new row(s) into the table, the page should stay as it was without move.
The problem I got is: The scroll bar automatically scroll back to top after a row is inserted.
I tried to control it by using JavaScript code as following which I expected work, but it does not. The page still scroll back to top after the insertion.
Looks like APEX has something overwrite my effort or I missed something in the template? The region is using APEX "Report region" template.
Here is the psudo code of my JavaScript function.
function insertRow() {
//get current scrollbar position
var x= (document.all)?document.body.scrollLeft:window.pageXOffset;
var y= (document.all)?document.body.scrollTop:window.pageYOffset;
// do insert
....
//reset scrollbar position as it was
window.scrollTo(x, y);
}
If anyone of know how to fix this, please let me know. Thanks in advance.