SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Europe
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    my popup script works only when the page is 100% loaded, help me fix that

    I'm using java script to pop-up a little page after closing the main one, but i have a problem
    the pop-up page, actually pops up only when the main page is fully loaded!
    I need it to be popped up even when the page isn't 100% loaded
    here is the script which i'm using
    "
    <script>

    var unloadX = (screen.width/2)-200;
    var unloadY = (screen.height/2)-150;
    var pos = "left="+unloadX+",top="+unloadY;
    var exit=true;

    function unload(){
    if (exit){
    unloadWindow = window.open("wait.htm","Wait_pls","scrollbars=yes,width=400,height=300,"+pos);
    }}

    </script>
    "
    ^this is in the header

    in the body part i have OnUnload="unload()"

    I use exactly this script cause it allows me to exclude the loading of the popup when link is clicked with this
    onClick="exit=false"


    so, in short
    i need script who pops up a page on close, it must pops up a page even when the main page is not 100% loaded and allows the links to be excluded, cause i want the page to popup only on closing of the main page, and not when surfer follows a link

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well...that little trick with the onclick handler won't stop the function from being called if the user hits the 'back' button, or uses an OS menu, or navigates by any other means. Detecting a close, rather than just a document unloading, is difficult to do accurately. Anyway, you should get an unload event even if the page isn't fully loaded. Did you put the code up as 'high' as possible?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    var unloadX = (screen.width/2)-200;
    var unloadY = (screen.height/2)-150;
    var pos = "left="+unloadX+",top="+unloadY;
    var exit=true;
    
    onunload = function()
    {
         if (exit)
              unloadWindow = window.open("wait.htm","Wait_pls","scrollbars=yes,width=400,height=300,"+pos);
    }
    
    </script>
    ............
    ::: certified wild guess :::

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Europe
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adios
    Well...that little trick with the onclick handler won't stop the function from being called if the user hits the 'back' button, or uses an OS menu, or navigates by any other means. Detecting a close, rather than just a document unloading, is difficult to do accurately. Anyway, you should get an unload event even if the page isn't fully loaded. Did you put the code up as 'high' as possible?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    var unloadX = (screen.width/2)-200;
    var unloadY = (screen.height/2)-150;
    var pos = "left="+unloadX+",top="+unloadY;
    var exit=true;
    
    onunload = function()
    {
         if (exit)
              unloadWindow = window.open("wait.htm","Wait_pls","scrollbars=yes,width=400,height=300,"+pos);
    }
    
    </script>
    ............
    absolutely true, but there is no onclose function
    the only i know is onunload, and i'm forced to use it, just cause there is not another.......

    the script is in the header......
    what can be the problem?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Europe
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nobody knows?


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
  •