SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot arthaus's Avatar
    Join Date
    Jun 2002
    Location
    Pasadena, CA
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onLoad Event Help

    Hi all,

    I've been using the following "Open Centered window" (coded by Travis Beckham).

    Q: How can I use it as "onLoad" event? ...rather than a normal link.

    Code:
    // Centered pop-up window
    function openWindow(url, name, width, height, scroll){
    	var x = (screen.availWidth-width)/2;
    	var y = (screen.availHeight-height)/2;
    	scroll = scroll ? "scrollbars=yes,resizable=yes," : "scrollbars=no,resizable=no,";
    	window.open(url,name,"toolbar=no,location=no,status=no,menubar=no,"+scroll+"width="+width+",height="+height+",screenX="+x+",screenY="+y+",top="+y+",left="+x);
    }
    Normal LINK usage:
    Code:
    <a href="http://www.mydomain.com/example.htm" onclick="openWindow(this.href, 'example', 600, 400, false);return false;" onfocus="blur();">My Link!</a>
    Thankx in advance,
    Arthur

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Erm, surely:

    Code:
    <body onLoad="javascript: openWindow(this.href, 'example', 600, 400, false);">
    orrr, in the head of the document:

    Code:
    <script language="JavaScript" type="text/javascript">
    openWindow(this.href, 'example', 600, 400, false);
    </script>
    G


Bookmarks

Posting Permissions

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