homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

JS onLoad or head script
to control window size

 7:09 pm on May 21, 2003 (gmt 0)

I'm redoing our website, and not sure which way to go on window sizing. I want to control the size on open/load not as a pop-up.

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">
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));

Any ideas on which way to go? Should I leave out the preload images and just go with a onLoad="resizeTo(o,0);"?




 7:12 pm on May 21, 2003 (gmt 0)

Welcome to WebmasterWorld Maxformed,

as to
can there be two onLoad handlers?

I use 2 on some pages like so


 7:45 pm on May 21, 2003 (gmt 0)

Thanks. I was getting a little confused. The onLoad is in the Body of the html and I'm not sure how to add the resizeTo after the "MM_PreloadImages".

Is it possible?


 7:49 pm on May 21, 2003 (gmt 0)


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.


 7:55 pm on May 21, 2003 (gmt 0)

That makes a lot of sense. I think that's my direction. Thanks so much, jatar_k.


 8:16 pm on May 21, 2003 (gmt 0)

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.


 8:20 pm on May 21, 2003 (gmt 0)

good point, tedster.

I almost never use onload but I haven't ever had the problem there. I have had the problem in onclick before but I dont have a specific site/example I can think of.

The intermittent problem with onClick has made me put it everywhere just to be paranoid.


 3:36 am on May 22, 2003 (gmt 0)

Hi All

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.


<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
<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" />

Would be great if all browsers supported it and all operating systems came with perl by default. ;)


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved