...

View Full Version : OnUnload - popup option window.



lets
08-08-2004, 05:04 PM
My understanding at this point is that an OnUnload command in the body tag calls a java script when someone leave the web page.........?

What I'm trying to do is when someone leaves a particular page, a small window pops up asking them a question, and gives a button for either "yes" or "no". Click no and off they go to their originally chosen destination, click yes, and they either get rerouted to a page other that where they had originally wanted to go, or they get a specific page that opens in a new window.

Just so no one thinks I'm trying to spam people :p, My intentions are to use this on an "confirmation of order" page that is the final page someone see's after purchasing a product from my web site. I'd like to ask people if they'd like to post a review of their "shopping experience".

Any help, assistance, or even pointing me in a direction to look would be greatly appreciated. I really haven't a clue how to do this, or where to begin.

Thank you.

jamescover
08-08-2004, 07:14 PM
My intentions are to use this on an "confirmation of order" page that is the final page someone see's after purchasing a product from my web site. I'd like to ask people if they'd like to post a review of their "shopping experience".

Why not incorporate the survey into the confirmation page...a lot of people don't like surprises, no matter how well intended.




-james

lets
08-08-2004, 07:23 PM
Have already done so...... Problem is the page has a lot of information, and a lot of other links on the page. I've talked to a lot of my customers and most have said they actually missed this part and all have said they wouldn't be offended at all if I incoorperated this type of "pop up window".

I've considered other options, but all of them seem to me to be MUCH more "spam like" (something I'm persoanlly very much against) and the last thing I want to do is take atention away from reading the important info on this poge concerning customers orders. My preferance really would be to remove the current text regarding the review so people would see the page as being smaller, meaning they would more likely read the entire page, then have this pop up when they exit.

jamescover
08-08-2004, 08:15 PM
Okay, do you need to have it pop up after the browser window is closed. NN doesn't support onunload...how about after the order is placed, forward them to another page....?


-james

lets
08-08-2004, 09:15 PM
I understand that this "feature" may not be supported by all browsers, and that's ok. It would still increase the number of people being made aware of it.

After an order is placed is when they now go the page I want to add the "feature" to, and I need them to go to this current page as it contains a bit of important info regarding placed order, shipping and receiving of their order etc..

jamescover
08-08-2004, 11:49 PM
It would look something like this:


<script>
<!--

function xitConf(){

var conf = confirm("WHERE DO YOU WANT TO GO?\n\r\n\rClick \"OK\" for: somePage.html\n\r or \"Cancel\" for: someOtherPage.html");

if (conf == true){
var newWin = window.open("http://somePage.html","","");
} else {
var newWin2 = window.open("http://someOtherPage.html","","");
}
}

//-->
</script>

<body onUnload="javascript:xitConf();">

But this will also produce a confirm box on reload...I can't think of a workaround for this offhand.


-james

lets
08-09-2004, 04:47 PM
close, I think, and I really appreceate the effort.

At least with this example I might be able to better explain things. What I need is something similar, that asks a question like that (WHERE DO YOU WANT TO GO?, but more like, would you like to go here instead?), but, if they click OK it sends them to a predetermined page of my choice, and if they click cancel it send them off on their originally chosen destination (either a link they clicked on the page, an address they typed into the address bar, or a bookmark they clicked.) I like the idea that if they do click OK, the the page opens in a new window.

thanks for all your help (and concerns)

lets
08-09-2004, 05:13 PM
BY GOSH! Think I may have it.......... could you look at this and let me know if you see any problems?




<body bgcolor="#FFFFFF" onUnload="javascript:xitConf();">

<script>
<!--

function xitConf(){

var conf = confirm("Would you like to help us (and others) by posting a review of your shopping experience?");

if (conf == true){
var newWin = window.open("http://www.rhtubs.com/cgi-bin/reviews.pl","","");
} else {
return;
}
}

//-->
</script>

jamescover
08-09-2004, 05:33 PM
<script>
<!--

function xitConf(){

var conf = confirm("Click \"OK\" to continue,\n\r or \"Cancel\" to visit: http://www.hotbot.com");

if (conf == true){
return true;
} else {
window.location.href = "http://www.hotbot.com";
}
}

//-->
</script>






<body onUnload="javascript:xitConf();">


-james

jamescover
08-09-2004, 05:45 PM
I didn't know you responded before I answered...If you still want to open another window, you will have to catch the request to go someplace else:


<script>
<!--

function xitConf(){

var conf = confirm("Would you like to help us (and others) by posting a review of your shopping experience?");

if (conf == true){
var newWin = window.open("http://www.rhtubs.com/cgi-bin/reviews.pl","","");
window.location.href = this.location.href;
} else {
return true;
}
}

//-->
</script>


<body onUnload="javascript:xitConf();">


-james

lets
08-10-2004, 06:19 PM
I can't express how thankful I am to you for your help......... I made a minor change and came up with;

<body onUnload="javascript:xitConf();">

<script>
<!--

function xitConf(){

var conf = confirm("Would you like to help us (and others) by\n\r posting a \"review\" of your shopping experience?");

if (conf == true){
window.location.href = "http://www.rhtubs.com/cgi-bin/reviews.pl";
} else {
return true;
}
}

//-->
</script>

not only does it work perfectly, but the customers I've asked about it so farr all say they don't feel it's intrusive at all. There's one last thing I think might be a great "feature" to add. Would there be a way, perhaps through the use of a cookie, to prevent the "pop-up" from occuring for anyone that has clicked the "OK" button in the past (I"d like the "pop-up" to still be seen by people that clicked "cancel"?

jamescover
08-10-2004, 08:16 PM
Would there be a way, perhaps through the use of a cookie, to prevent the "pop-up" from occuring for anyone that has clicked the "OK" button in the past (I"d like the "pop-up" to still be seen by people that clicked "cancel"?

Yes. Do a search for "cookie," and you should be able to find something to suit your needs.


-james



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum