Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,740

    * (no popups) Closing window events :|

    Hey Everyone,

    I have a problem with a script im working. What i want it to do is when the window (this is not a popup just the single window) is closed or the URL is changed i would like the window to be redirected to another place. I have gotten the script to work with an alert however when it comes to changing the URL it wont work... MY code below:
    <HTML>
    <HEAD>
    <SCRIPT>
    function GoingAway()
    {
    alert("Maybe you are closing the browser");
    }
    </SCRIPT>
    </HEAD>
    <BODY onbeforeunload="GoingAway()">
    </BODY>
    </HTML>

    The above code works however when i try to chaneg the alert function to "window.location=.." then it wont work. As follows
    <HTML>
    <HEAD>
    <SCRIPT>
    function GoingAway()
    {
    window.location="http://www.google.com";
    }
    </SCRIPT>
    </HEAD>
    <BODY onbeforeunload="GoingAway()">
    </BODY>
    </HTML>

    Does anyone know of a way i can accomplish this?
    Just to save all of you who are going to tell me to use popups time, in this application i cannot use popups Thanks everyone!
    <<< Please see Forum Guidelines for signature setup. >>>

  2. #2
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,345
    If you close the browser.. you close it??

    the only thing you will be able to do it to open a new window, but getting redirected on a window that IS closing will not work..

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

  3. #3
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,740
    Alright i thought that may be the case...

    Is there a way to make a small popup as they close the window? Thanks
    <<< Please see Forum Guidelines for signature setup. >>>

  4. #4
    use onUnload instead of onbeforeunload
    To assume perfection is merely a display of ignorance.

  5. #5
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,740
    <HTML>
    <HEAD>
    <SCRIPT>
    function GoingAway()
    {
    window.open('http://www.google.com','mywin',
    'left=20,top=20,width=50,height=50,toolbar=0,resizable=0');
    }
    </SCRIPT>
    </HEAD>
    <BODY onUnload="GoingAway()">
    </BODY>
    </HTML>

    I tried this and it wont work either... Am i just totally off here or do i have some sort of syntax error?
    <<< Please see Forum Guidelines for signature setup. >>>

  6. #6
    What exactly are you trying to do? open a new window, go to aurl in the current window, alert a message, or multiple, etc.?
    To assume perfection is merely a display of ignorance.

  7. #7
    PHP Code:
    <HTML>
    <
    HEAD>
    <
    SCRIPT>
    function 
    GoingAway() {
        
    alert("You browser is being redirected");
        
    window.open("http://www.google.com","MyWindow","left=0,top=0,width=800,height=600,toolbar=no,resizable=no");
    }
    </SCRIPT>
    </HEAD>
    <BODY onBeforeUnload="GoingAway()" />
    </HTML> 
    To assume perfection is merely a display of ignorance.

  8. #8
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,740
    AHA! Thank you so much hotlinkHost!!!
    I owe you one!
    <<< Please see Forum Guidelines for signature setup. >>>

  9. #9
    No problem. If you want no pop up looking version then don't use any of the extra features (3 column in quotes on window.open).
    To assume perfection is merely a display of ignorance.

  10. #10
    Join Date
    Jun 2004
    Location
    Bay Area -USA
    Posts
    1,740
    The only problem with any kind of pop up... being re-directed is pretty essential in my script and if the person has a popup blocker (like many people do) then the entire process is skipped.
    Thats why i wanted to see if there was a way to do it without popups...

    Better yet.. is there a way to make a "sort of" popup that most popup blockers will miss and yet the window will still do the trick?
    I just need one little php script to be run as a way of cleaning up before someone closes the window.
    Last edited by VolkNet; 06-25-2004 at 06:16 PM.
    <<< Please see Forum Guidelines for signature setup. >>>

Posting Permissions

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