glenngv
01-15-2004, 09:21 AM
No. Why don't you want that window.onload thing?
Maybe you want it shorter.
<script type="text/javascript">
onload = function(){document.frm['t_Login'].focus()}
</script>
angiras
01-15-2004, 09:50 AM
ok shorter is allready good
thank you !
<input type="text" " id="t_Login" onload="SetInitialFocus" />
Anyway, that seems not correct to me, as onload is an excusive window's event handler.
window.onload = function (or onload = function , which is the same) and
<body onload="function"> are correct.
Probably <tagOtherThanBody onload> will fire exactly like <body onload> but I am affraid that if there will be 2 or more of these, the code will be useless, if not even will bring javascript errors...
angiras
01-15-2004, 11:01 AM
then no possibility to write the setFocus directly into the first control without any external script tag ?
without any external script tag
but why? :confused:
It is true that you may fire a function using something like
"javascript:a_function()" but you need by all means an eventhandler to fire it this way....
angiras
01-15-2004, 12:16 PM
you can write onkeypress:retrun false;
then why not
onload:setFocus;
?
:-)
brothercake
01-15-2004, 12:43 PM
Because form elements don't load anything. Images, frames, documents - they all load, and that's why they have load events.
You could try the readyState property - that might return a value, in IE at least.
sage45
01-15-2004, 12:46 PM
angiras - The code provided by glenngv will do exactly what you would like for it to do... You can set focus on an object...
-sage-
angiras
01-15-2004, 02:11 PM
yes The code provided by glenngv works fine ! no prob !
thanks