SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make a popup window appear behind main page?

    Can somebody tell me how I can make a popup window appear behind the main browser window by modifying the script below to do this? I would like it so the popup will load but they won't see it until they close the main window.

    Code:
    <script language="JavaScript" type="text/javascript">
    <!-- Begin
    var popupWin
    function openWindow() {
      popupWin = window.open("http://www.domain.com", 'win', 'menubar=yes,status=no,toolbars=no,resizable=yes,scrollbars=yes,width=800,height=600')
    }
    // End -->
    </script>
    Any help would be greatly appreciated!
    John Saunders

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After you open your popup, give the focus back to the parent window, like so:

    Code:
    <script language="JavaScript" type="text/javascript">
    <!-- Begin
    var popupWin
    function openWindow() {
      popupWin = window.open("http://www.domain.com", 'win', 'menubar=yes,status=no,toolbars=no,resizable=yes,scrollbars=yes,width=800,height=600')
    
    //bring parent window to forefront
    parent.focus();
    }
    // End -->
    </script>
    Last edited by makeda; Feb 16, 2003 at 14:01.

  3. #3
    Git-R-Done
    Join Date
    Nov 2001
    Posts
    1,194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Makeda! If I wanted to include the function in an global external javascript file (as opposed to the actual page), would I need to move the parent.focus above the closing bracket?
    John Saunders

  4. #4
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops. Typo on my behalf. Yes, that line should come before the closing bracket. I'm going to edit my post to fix it...


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
  •