Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Edit JS to work as onload event

    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?

    Code:
    <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.
    Last edited by dommy; 12-14-2006 at 12:02 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •