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 12 of 12
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OnUnload - popup option window.

    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 , 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.

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by jamescover; 08-08-2004 at 07:16 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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..

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by jamescover; 08-08-2004 at 11:53 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #7
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

  • #8
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #9
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <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
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #10
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    <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
    Last edited by jamescover; 08-09-2004 at 05:50 PM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #11
    New Coder
    Join Date
    May 2004
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"?

  • #12
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

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