Results 1 to 10 of 10
-
06-25-2004, 05:21 PM #1Web Hosting Master
- 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. >>>
-
06-25-2004, 05:28 PM #2Web Hosting Master
- 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...
-
06-25-2004, 05:30 PM #3Web Hosting Master
- 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. >>>
-
06-25-2004, 05:32 PM #4Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 1,310
use onUnload instead of onbeforeunload
To assume perfection is merely a display of ignorance.
-
06-25-2004, 05:39 PM #5Web Hosting Master
- 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. >>>
-
06-25-2004, 05:42 PM #6Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 1,310
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.
-
06-25-2004, 05:58 PM #7Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 1,310
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.
-
06-25-2004, 06:02 PM #8Web Hosting Master
- 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. >>>
-
06-25-2004, 06:04 PM #9Web Hosting Master
- Join Date
- Jan 2004
- Posts
- 1,310
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.
-
06-25-2004, 06:07 PM #10Web Hosting Master
- 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. >>>