PDA

Click to See Complete Forum and Search --> : window_onload()


turfbult
May 9th, 2001, 02:20 AM
Hello,

Can anyone please give me some example code of the window_onload() event!?

I'm not very clued up with Java. Do you just put this event right at the top of your page and it will "fire" whenever the page is loaded??

What I want to do is set the focus to "textbox1" when the page loads.

Thanks,
T

kayoca
May 9th, 2001, 02:51 AM
You can use this little tiny script for window_onload()

<title></title>
<script language=javascript>
<!--

function window_onload() {

}

//-->
</script>
</head>

And place this code in your body tag.

language=javascript onload="return window_onload()"

But i dont know how you can focus a object on you pages :(

Jeh
May 9th, 2001, 03:39 AM
lo,

this may be worth a try.

put this bit in between the <head></head> tags:


<script language="Javascript">
<!--
function SetFocus(formfield){

var theForm = document.forms['FORMNAME']
theForm[formfield].focus();

}
//-->
</script>


Then in the <body> tag add:

onload="SetFocus('FIELDNAME')"

just replace the FORMNAME and FIELDNAME with the correct names of the form and field you wish to use.

Hope that helps, well hope it works tbh:p

turfbult
May 9th, 2001, 04:20 AM
Thanks guys!!