...

View Full Version : Edit JS to work as onload event



dommy
12-13-2006, 07:04 PM
Can someone kindly help me - I'm not so savvy with js.
I want to size a webpage to 520 x 720 and center it.. thing is it has to happen on body onload. Not as a popup using param set in the link...

So that said, how do I edit this to run in a page that is going to be resized and centred onload?


<SCRIPT LANGUAGE="JavaScript">
<!--

function popup( filename, params, width, height, resizable, scrollbars, windowName, centered )
{
if ( width == 0 ) width = screen.availWidth - 20;
if ( height == 0 ) height = screen.availHeight - 20;
if ( centered == true ) {
topX = (screen.availWidth/2)-(width/2);
topY = (screen.availHeight/2)-(height/2);
} else {
topX = 20;
topY = 20;
}
if ( params != "" ) params = "?" + params;
window.open( filename + params, windowName, "resizable=" + resizable + ",scrollbars=" + scrollbars + ",top=" + topY + ", left=" + topX + ",width=" + width + ",height=" + height);
}

PopUp = function( width, height )
{
this.page = "";
this.params = "";
this.width = width;
this.height = height;
this.resizable = "yes";
this.scrollbars = "auto";
this.windowName = "win" + new Date().getMilliseconds();
this.centered = true;
}

PopUp.prototype.getPageLink = function()
{
return this.page + (this.params != "" ? "?" + this.params : "");
}
// -->
</SCRIPT>

and this is the code that executes the popup - but I want this to happen on the page loading not by clicking a link to the page.


<a href="javascript: popup('testlink.asp','',520,720,'no','no','popup',true)">LINK</a>

Many thanks

I know I need to punch the data from the link into the script - but this is where I get stuck.
I know then that I can run body onload and call the popup function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum