Forum Moderators: open
Currently I have images preloading on Load - can there be two onLoad handlers?
I have a script I found (not sure where) that works fairly well, except for the centering part. See here.
<script language="JavaScript" type="text/JavaScript">
//tmtC_Resize_Window
tmt_Resize_WindowX = (screen.availWidth)*.95;
tmt_Resize_WindowY = (screen.availHeight)*.95;
if (parseInt(navigator.appVersion) >= 4) window.moveTo((screen.availWidth/2)-(tmt_Resize_WindowX/2),(screen.availHeight/2)-(tmt_Resize_WindowY));
self.resizeTo(tmt_Resize_WindowX,tmt_Resize_WindowY);//tmtC_Resize_WindowEnd
</script>
Any ideas on which way to go? Should I leave out the preload images and just go with a onLoad="resizeTo(o,0);"?
Thanks
I never know if you need the "javascript:" or not sometimes when i don't have it weird things happen.
tmtC_Resize_Window doesn't look to be a function though. You would need to make it a function and then put the function call into the onload in the body as above.
I never know if you need the "javascript:" or not sometimes when i don't have it weird things happen.
The minute you've typed "onLoad=" you've already tapped into javascript - an event handler in particular. So the extra "javascript:" protocol is coming a bit late to the party, from what I know.
It would be interesting to look at an example of a misfire on this. As far as I know, the special "javascript:" protocol is only used in anchor tags, when a js function is invoked as the direct argument of the href= attribute. You shouldn't even need it in an onClick= attribute, although I often see it there.
javascript is the default client-side scripting language in most browsers, so you should be OK without the "javascript:". However, you can use other scripting languages, such as VBScript or, if you have perl installed on the client machine, perlscript.
Example:
<html>
<head><title>PerlScript sample</title>
<!-- Assumes you have Perl installed on your desktop...
........ not talking perl for cgi here; talking on your desktop, so not suitable for public Internet sites.
........ also, only works in MS IE 5.0.x or higher
-->
</head>
<body>
<form action="" Name="my_form">
<input name="ReadOut" type="Text" size="24" value="0" />
<input name="Inc" type="Button" value="add one" onclick="perlscript:$window->document->my_form->Readout->{'Value'} += 1" />
</form>
</body>
</html>
Would be great if all browsers supported it and all operating systems came with perl by default. ;)
Shawn