SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Close popup when lanching window unloads

    Hi all,

    I have this page that a user uses to upload a PDF. I want a small popup to come up when they hit the upload button to promt the user to wait. This part is fine and works but I need the popup to close when the upload is complete. The way I have aproched it is to have a function that pops the window up:

    Code:
    function waitPop(page){
    var intScrWidth = (window.screen.width/2) - (100 + 10);
    var intScrHeight = (window.screen.height/2) - (25 + 40);
    var waitAlert=window.open(page,"winname","width=200,height=50,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,left=" + intScrWidth + ",top=" + intScrHeight + ",screenX=" + intScrWidth +",screenY=" + intScrHeight);
    //bring the newly opened window into focus(front of the screen)
    waitAlert.focus();
    }
    and then a function called with <body onUnload="closeWait();"> as seen below

    Code:
    function closeWait() {
    waitAlert.close();
    }
    I have followed the advice in a prior post and put

    Code:
    var waitAlert;
    to create a global variable above these two functions.

    So the popup comes up but will not shut for anything. Any help will be much appreciated cheers

    Slarti

  2. #2
    SitePoint Enthusiast Slarti42's Avatar
    Join Date
    May 2001
    Location
    UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Done it!!! wahooo!

    I've sorted the problem.

    Here's how:
    Having popped the window up and given it focus, it seemed that scripts in the opener window were not working or not able to target the window corectly. So to get around this I put the code:
    Code:
    <body onUnload="self.focus();">
    Then in the page that popped up I put:
    Code:
    <body onBlur="self.close();">
    The only problem that could arise here is if they click back to the page they will close the warning page before the file has finished. I'm not to bothered because they will have been warned in the popup to wait for the file to finish.

    I'm amazed I worked that out. I need to sit down now!!

    Slarti


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
  •