#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    127
    Rep Power
    17

    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
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    127
    Rep Power
    17
    bump
  4. #3
  5. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2795
    You can't unload a page before it is loaded.

    Are you trying to do something like this?
    PHP Code:
    <html>
     <
    head>
      <
    script>
       function 
    launch()
        {
          
    window.open ('newWindow.html','main',config='width=500 height=500 scrolling=yes,toolbar=no');
          
    window.opener=null;
          
    window.close();
        }
      
    </script>
     </head>
     <body onLoad="launch();"></body>
    </html> 
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    127
    Rep Power
    17
    Originally posted by PHP-Newb
    You can't unload a page before it is loaded.

    Are you trying to do something like this?
    PHP Code:
    <html>
     <
    head>
      <
    script>
       function 
    launch()
        {
          
    window.open ('newWindow.html','main',config='width=500 height=500 scrolling=yes,toolbar=no');
          
    window.opener=null;
          
    window.close();
        }
      
    </script>
     </head>
     <body onLoad="launch();"></body>
    </html> 
    not sure if your is the same....
    btw why <body onLoad ?
  8. #5
  9. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2795
    onLoad, the opener page will close.
  10. #6
  11. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Mexico City
    Posts
    4
    Rep Power
    0
    Hi, i need something like that, i've tried the code posted here, but it didn't work

    Im not sure if it's because of this..

    1) someone type the url http://odie27.com/index.php
    2) this show a login page, and after user types username and password, it open a popup window named main.php, i want to close index.php, but with the code above didn't work

    only thing different i see is that in index.php, the action in the form is pointed to PHP_SELF , because i need to discriminate if its a normal or administrator user, and then open either the popup main.php or the page admin.php , and then, i need to close the index.php only if the user has authenticated as a "normal" user and opened the popup..

    here's the code..

    in index.php

    PHP Code:
    <html>
    <head>
    <script type="text/JavaScript">
    function openNewWin(pagina)
    {
       window.open(pagina, '', 'toolbar=no, locationbar=no, scrollbars=auto,width=800,height=600')
       window.opener=null;
       window.close()
    }
    </script>
    </head>

    <?
      
    if (isset($_POST['submit']))
       { 
         
    //authenticate and identify type of user, normal or administrator
         
         
    if($usuario == "administrador")
         {
          echo 
    "<BODY bgcolor='#e6e6e6'      onLoad=window.setTimeout(\"location.href='admin.php'\",1)>";
         }
        else
         {
          echo 
    "<BODY bgcolor='#e6e6e6'    onLoad=\"openNewWin('main.php?usuario=$usuario');\">";
         }
       }
     else
      {
    ?>
      <body>
      <form action="<? echo $_SERVER['PHP_SELF']?>" method="post">
         //normal form
      </form>
    <?
       
    }
    ?>
    </body>
    </html>
    i dont know if im being clear, but thanx in advance
    Last edited by odie27; February 17th, 2004 at 01:36 PM. Reason: missing code
  12. #7
  13. No Profile Picture
    Slightly Disturbed
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    200
    Rep Power
    15
    <script type="text/JavaScript">
    function openNewWin(pagina)
    {
    window.open(pagina, 'NO_SPACES_IN_NAME', 'toolbar=no, locationbar=no, scrollbars=auto,width=800,height=600')
    }
    </script>

    if (isset($_POST['submit'])) :
    //authenticate and identify type of user, normal or administrator

    if($usuario == "administrador")
    {
    echo "<BODY bgcolor='#e6e6e6' onLoad=window.setTimeout(\"location.href='admin.php'\",1)>";
    }
    else
    {
    echo "<BODY bgcolor='#e6e6e6' onLoad='openNewWin(\"main.php?usuario=$usuario\");'>";
    }
    else:
    endif;
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    127
    Rep Power
    17
    hey, what about my question?

    how to make the script to popup the page even when the page isn't 100% loaded
    the script is in the header, but works only when the page is loaded till the end......
  16. #9
  17. Sockless.net
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Purmerend, the Netherlands
    Posts
    33
    Rep Power
    15
    Try this,

    Note: put following code between </head> and <body>
    Code:
    <script language="javascript/text">
    function pop()
    {
    var newWin;
    newWin =window.open("http://yoursite.php","statics",'resizable=no,scrollbars=yes,width=800,height=600,toolbar=yes')
    }
    </script>
    and then in your body:
    Code:
    <body onUnload="pop();"></body>
    Last edited by dwightjelee; February 18th, 2004 at 08:53 AM.
  18. #10
  19. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2795
    odie, my code didn't work for you because you removed parts of it.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    127
    Rep Power
    17
    Originally Posted by dwightjelee
    Try this,

    Note: put following code between </head> and <body>
    Code:
    <script language="javascript/text">
    function pop()
    {
    var newWin;
    newWin =window.open("http://yoursite.php","statics",'resizable=no,scrollbars=yes,width=800,height=600,toolbar=yes')
    }
    </script>
    and then in your body:
    Code:
    <body onUnload="pop();"></body>
    hm, this one seems not work at all

    anyway i need the functions of my script (excluding links, and centering) but to be opened even if the main page isn't 100% loaded
  22. #12
  23. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,005
    Rep Power
    2795
    If the page is not loaded, then the javascript is not loaded. You can not do it.

IMN logo majestic logo threadwatch logo seochat tools logo