Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Code to stop user leaving Page

Options
  • 27-02-2010 5:07pm
    #1
    Closed Accounts Posts: 18


    Hi,
    I was wondering, I was searching on Google, I see this on websites like www.theaffiliatecode.com [Mod edit: Clicking on that link leads to a very annoying javascript jail], I want when someone tries to leave the page it says a message, when they click cancel they go onto another web page of my choice...
    Tagged:


Comments

  • Registered Users Posts: 11,977 ✭✭✭✭Giblet


    Wire up the onunload event.

    <body onUnload="MyFunction()">

    function MyFunction(){
    do annoying crap here.
    }

    That page just pops up a confirmation dialog using
    if(confirm('Do you want to leave?'))
    {
    //Do yes
    }
    else
    {
    //Do no
    }
    . I'd advise against using these. Any website that ever uses these will never be visited by me ever again.


  • Closed Accounts Posts: 18 kawadri


    Giblet wrote: »
    Wire up the onunload event.

    <body onUnload="MyFunction()">

    function MyFunction(){
    do annoying crap here.
    }

    That page just pops up a confirmation dialog using
    if(confirm('Do you want to leave?'))
    {
    //Do yes
    }
    else
    {
    //Do no
    }
    . I'd advise against using these. Any website that ever uses these will never be visited by me ever again.

    Thanks, if they click cancel I want them to be redirected to another page, got any ideas? Also where do I put my text? Thanks


  • Closed Accounts Posts: 8,016 ✭✭✭CreepingDeath


    kawadri wrote: »
    I want when someone tries to leave the page it says a message, when they click cancel they go onto another web page of my choice...

    Not very user friendly if you ask me.


  • Closed Accounts Posts: 18 kawadri


    Not very user friendly if you ask me.

    It gives them a discount :)


  • Registered Users Posts: 1,916 ✭✭✭ronivek


    kawadri wrote: »
    It gives them a discount :)

    Why not just have a clear banner/link/whatever which offers a discount from your main page?

    If I visited a site, decided I wanted to browse away from the page and got any kind of popup when I tried to leave in all likelihood I would never return.


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Yeah, it's not one really. I'm not suprised you're not getting much help.


  • Registered Users Posts: 118 ✭✭MyBusinez.com


    kawadri wrote: »
    Hi,
    I was wondering, I was searching on Google, I see this on websites like www.theaffiliatecode.com, I want when someone tries to leave the page it says a message, when they click cancel they go onto another web page of my choice...

    A bit of advice: If you want people to stay on your website preventing them from leaving is the worst way to do it as they will never visit again. You have to understand that on the internet, the user is in control, not the website.

    There is no real way of preventing people from leaving your website anyway as they can always just pull the plug on their computer and if you prevent them from leaving they might think there is a virus on your website or a virus on their computer coming from your website.

    You might as well stand at the door of your shop and not let people leave in order that they'll buy your product. Why not try offering them something that they'll like instead?


  • Registered Users Posts: 35,524 ✭✭✭✭Gordon


    kawadri, this kind of browser manipulation is unprofessional and will annoy users, I am quite angry at you for not putting a warning on that link tbh, firefox forced me to click ok 5 times when I closed the tab.

    If you are the business owner and have to force people to stay on your site, rethink your business and web design, you are doing something wrong. If you are the web designer doing this for the business, tell them that it will annoy and alienate customers and advise them against this bullying course of action.


  • Registered Users Posts: 40,038 ✭✭✭✭Sparks


    kawadri wrote: »
    It gives them a discount :)
    It'd have to be a very very large discount on something they're looking to purchase right then and there in order to not tick off whomever encounters it. Frankly, I think it's a bad idea that will do more to harm your site than to help it.


  • Registered Users Posts: 81,223 ✭✭✭✭biko


    Def a very bad idea. Put a contact number on the site so people can ring you and vent.


  • Advertisement
  • Closed Accounts Posts: 18 kawadri


    It's a bad idea to put a phone number on a ClickBank product, the thing is when you visit certain sites you can tell that it is a clickbank product or not...

    When the visitor sees that it's a clickbank product they try to navigate away to get a discount, I know the visitor is in control, I can't believe some are annoyed at me :) for not telling you that that website theaffiliatecode.com has a leaving message, I use firefox and I got one message saying to leave.

    The reason why I am asking you is because I don't want to pay http://exitsplash.com/ 97 dollars for this code...

    Take a look at http://exitsplash.com/ to see the benefits of this javascript code, plus that shop comment was quite funny but you're wrong, most stores you go into when you are about to leave without buying anything some will say "wait I will give you a discount" or something....


  • Closed Accounts Posts: 18 kawadri


    Thanks for all the advice but this is what all cb products do...


  • Moderators, Arts Moderators Posts: 10,517 Mod ✭✭✭✭5uspect


    This is perhaps one of the most annoying things a website could do.
    Not only does it open an annoying popup with associated warning prompt it plays audio without your control.

    If a site did that to me I would never ever visit that site again.


  • Registered Users Posts: 3,140 ✭✭✭ocallagh




  • Moderators, Science, Health & Environment Moderators Posts: 8,886 Mod ✭✭✭✭mewso


    kawadri wrote: »
    most stores you go into when you are about to leave without buying anything some will say "wait I will give you a discount" or something....

    Most stores bar maybe every online shop I've ever been to. You are making the mistake of looking at this from your point of view (how can I force them to buy) instead of your customers (how can I encourage them to want to buy).

    You get sales by making your site pleasant to visit, easy to navigate, quick to process purchases and deals that are obvious not by saying I know you should buy this so go buy it.

    If you owned a real shop would you block the door every time a customer was leaving and shout at them "Have you seen the 2 for 1 deal over there". It's exactly the same thing.


  • Closed Accounts Posts: 9,700 ✭✭✭tricky D


    kawadri wrote: »
    It gives them a discount :)

    Meh.

    It also gives them a massive pain in the behind. It gives them the resolve to hate the site, the brand and everything associated with it and to never ever visit it again. Way to do business!!


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Yeah, repeat business is far more important than making a single sale. I'm going to close this now, it serves no further purpose.


This discussion has been closed.
Advertisement