I try to get the values form Button elements:
<script>
var elmnt = document.getElementById('<%= Button1.ClientID %>');
var elmnt2 = document.getElementById('<%= Button2.ClientID %>');
var x = elmnt.scrollLeft;
var y = elmnt.scrollTop;
var x2 = elmnt2.scrollLeft;
var y2 = elmnt2.scrollTop;
function ToTopOfPage(sender, args) { setTimeout("window.scrollTo(x, y)", 0); }
function ToTopOfPage2(sender, args) { setTimeout("window.scrollTo(x2, y2)", 0); }
</script>
When I click on the Button1 or Button2 does not jump to the element Here is the Button codes:
Button1:
ScriptManager.RegisterStartupScript(this, Page.GetType(), "ToTheTop", "ToTopOfPage();", true);
Button2:
ScriptManager.RegisterStartupScript(this, Page.GetType(), "ToTheTop", "ToTopOfPage2();", true);
When I add some values to scrollTo() method for example window.scrollTo(2000,1000) the method works fine but when I assign a dinamic value does not work window.scrollTo(x,y).