Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,776
    Thanks
    19
    Thanked 155 Times in 146 Posts

    Question sleep() question

    I have this code:

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE></TITLE>

    </HEAD>

    <BODY>


    <?

    echo 'HELLO WORLD!';

    sleep(10);

    ?>


    <script language="JavaScript">
    <!--

    window.opener.location.href = window.opener.location.href;

    if (window.opener.progressWindow)
    {
        window.opener.progressWindow.close()
    }

    window.close();

    -->
    </script>


    </BODY>
    </HTML>
    I want to know why I don;t see the phrase "HELLO WORLD!" on the screen for 10 seconds before the javascript closes the window....

    Right now, I see a blank screen, then the window closes....How come?

    thanks..


    Nevermind, this is resolved. I found the answer here: sleep function help
    Last edited by chump2877; 02-10-2006 at 06:48 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Because you sleep for 20 seconds on the server side, and then the script finishes, php outputs all the data in the output buffer and then the page is loaded but closed instantly by the javascript.

    PHP is not intended to manipulate the client side.

    [edit:] Didn't see you'd resolved it.. oh well, just another explanation for future searches.
    Omnis mico antequam dominus Spookster!

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    was just gonna point you in the direction of my thread


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •