HTML strict Mode Javascript problems with ASP.net

R

ree321

When I am using Strict Mode HTML declaration
http://www.w3.org/TR/html4/strict.dtd

I am having issues with setting the scroll poistion in the onload
functions

onLoad="startBodyScroll();monitorBodyScroll();"

I use to two javascript functions to keep & set the scroll position on
a page.

//This sets the scroll position of the window to the value specified
in the hidden input
function startBodyScroll(){
var strPos =
document.getElementById("inpHidScrollPage").value;


if (document.documentElement &&
document.documentElement.scrollTop)
{
document.documentElement.scrollTop = strPos;

}
else {
document.body.scrollTop = strPos;
}
}



//This tells the page to let SetBodyPosition run when the window is
scrolled
function monitorBodyScroll(){
window.onscroll = SetBodyPosition;
}


// This records the scroll position od the scroll to hiddeninput
function SetBodyPosition(){

var inpHidName = "inpHidScrollPage";
var intY = 0;
if (document.documentElement &&
document.documentElement.scrollTop)
{
intY = document.documentElement.scrollTop;

}
else {
intY = document.body.scrollTop;
}


document.getElementById(inpHidName).value = intY;


}


Eventhough startBodyScroll() is run it is not able to set the scroll
position. But if I run a client side script in the ASP.net code.

The startBodyScroll() is able to set scroll position.

eg. this sets focus to a textbox
strS = "<SCRIPT
language='javascript'>document.getElementById('" + ctrlID +
"').focus();document.getElementById('" +

ctrlID + "').select();</SCRIPT>"

RegisterStartupScript("focus", strS)

THis happens in IE and Firefox.

Using ASP.net 1.1
 
R

ree321

Update : the setfocus only works when it forces the scroll to be
moved, i.e. the focus item has to below the initial load up page
layout.


So how do I get the scroll "initialise" with out using this set focus.
 
R

ree321

Found a solution on another site:

window.scrollBy(0, strPos)

to set the scroll length.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top