SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict Shawn Weeks's Avatar
    Join Date
    Aug 2003
    Location
    Charleston, S.C.
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make a centered popup?

    I consider myself a pretty advanced and knowedgable web developer, been doing it for about 7 years. However, in none of that time have I ever created a website that needed a centered popup. Ever.

    So, this client calls me up and tells me that they'd like to have a re-design of their site - they want to visit the homepage, and a page popup inside of a popup centered. Thing is, I know how to make JS popups, change width, height, etc, but I don't know how to make one pop up automatically AND centered.

    Er, help?

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't really help you right now, but I can tell you how it is accomplished in theory.

    Basically, you find the height/width of the screen, subtract the height/width of the popup window, then divide by 2, and use that to set the top and left values for window.open().
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    SitePoint Addict Shawn Weeks's Avatar
    Join Date
    Aug 2003
    Location
    Charleston, S.C.
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THanks, but I was looking for code

  4. #4
    SitePoint Member lazydog's Avatar
    Join Date
    Sep 2003
    Location
    on the farm
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shawn Weeks
    THanks, but I was looking for code
    Yeah I know, lol, I was lazy and busy, which is never a good combination.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  6. #6
    googlicious graymatter bvarvel's Avatar
    Join Date
    Sep 2002
    Location
    Katy, TX
    Posts
    956
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Funny you should ask... I was just working on this:


    PHP Code:
    <SCRIPT TYPE="text/javascript">
    <!--
    function 
    ShowPhoto(mylinkwintitle)
    {
    if (! 
    window.focus)return true;
    var 
    href;
    var 
    width 650;
    var 
    height 370;
    var 
    centerX=(screen.width-width)/2;
    var 
    centerY=(screen.height-height)/2;
    if (
    typeof(mylink) == 'string')
       
    href=""mylink;
    else
       
    href=""mylink.href;
    window.open(hrefwintitle'top='+centerY+',left='+centerX+',width='+width+',height='+height+',scrollbars=no');
    return 
    false;
    }
    //-->
    </script> 
    then just call it with:

    <a href="showpic.php?photoid=<?=$pid?>" title="See Larger Version" onmouseover="window.status='ShowPhoto';return true" onMouseOut="window.status='';return true" onClick="return ShowPhoto(this, 'Photo')">

  7. #7
    SitePoint Zealot
    Join Date
    Nov 2002
    Location
    canada
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or just do a search on dynamicdrive.com
    I've gotten scripts like that there. I think the link is called "browser window"
    HostVoice.net - When Hosts Compete, You Win
    Looking for a web host? Let them compete for your business.
    Submit a free request and receive offers within 15 minutes
    from qualifying hosts - Personal, business, NT, dedicated!


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
  •