Click to See Complete Forum and Search --> : Set Focus to the Top of Page


forumuser
05-28-2004, 11:44 AM
I want to set focus to an element on a web page. Currently when i set focus to this element, the element is positioned to the bottom of the current window. How can I get this element to be positioned at the top of the current window when it gains focus?

This is the function I am using:

<script language='javascript'>
<!--
function SetFocus(element){
document.getElementById(element).focus();
return true;
}
-->
</script>

Tage
05-30-2004, 02:45 AM
try making the window scroll to the bottom of the page first like so...<script language='javascript'>
<!--
function SetFocus(element){
window.scrollTo(0,document.body.scrollHeight);
document.getElementById(element).focus();
return true;
}
//-->
</script>The way you're using that function, I don't think you need to return a value. I could be missing something though.

Tage

forumuser
06-01-2004, 08:29 AM
Thanks Tage, that fixed the problem.