I want to know if this is possible

Discussion in 'HTML & Website Design' started by krame, Apr 28, 2008.

  1. #1
    Hey I barely know any html:

    This is what I want to do, when someone comes to my website, and they try to exit out, a little box pops up saying something like "blah blah blah are you sure you want exit?" they click yes or ok and another box pops up saying something else ect ect. Thanks!!
     
    krame, Apr 28, 2008 IP
  2. phoenix_ent

    phoenix_ent Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    last time i went to a site that did that i never went back. so you should think about it.
     
    phoenix_ent, Apr 28, 2008 IP
  3. sydneyaus

    sydneyaus Active Member

    Messages:
    1,110
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Agree with phoenix ent, there's many people who don't like that kind of pop ups.
     
    sydneyaus, Apr 28, 2008 IP
  4. krame

    krame Guest

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    eh....it's a shock site so yeah lol......I want it to be the most annoying thing possible.
     
    krame, Apr 28, 2008 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You mean like DP uses when you log out? As far as I know, you need Javascript for that, and even then I think it would only work if the user clicked a "Leave this site" button"... I mean, there's nothing you can do if someone just types a new address in their address bar anyway...

    Such a box is much more useful in asking people if they're sure they want to log out, or if they're sure they want to leave a secure (https) page... and the message box is only triggered when they either click on a submit button or a link with Javascript. I don't Javascript so I don't know exactly what it would be, but something like:
    in the <head> of your page:
    
    <script type="text/javascript">
    <!--//--><![CDATA[//><!--
    function theywanttologout() {
        if ( somethingaboutclickingthelink== '1') { [b]I think 1 means "true" but maybe you just use "true"?[/b]
            alert('Are you sure you want to log out?');
            return false; [b]<-- instead of this, you'll need something different so they can click OK and log out[/b]
        }
    }
      //--><!]]>
    </script>
    
    Code (markup):
    And if this is a <a href... that they're clicking, you'll need to have it be a NORMAL link so it works when there is no JS on the user's browser...
    
    <a href="whatever" rel="external">the link</a>
    
    Code (markup):
    And the Javascript will then need something like
    
    [b]after the "function theywanttologout()" line above[/b]
    if (!document.getElementsByTagName) return;
     var anchors = document.getElementsByTagName("a");
     for (var i=0; i<anchors.length; i++) {
       var anchor = anchors[i];
       if (anchor.getAttribute("href") &&
           anchor.getAttribute("rel") == "external") 
    ...
    
    Code (markup):
    That tells the Javascript to look for a real anchor (so anything that is the tag called "a" and has an href, meaning it goes somewhere (kinda redundant unless you have a's which are only for inpage links like
    <a name="something"></a>
    Code (markup):
    ) and also has the rel="external" attribute... so when that a is clicked, then the rest of the Javascript runs and I dunno what the popup box code is but I'm sure it's floating out there on teh Interwebs.

    But, it will not come just from someone typing a new address... and I'm pretty much in agreement with the others, sticking that message on any of your normal outgoing links will drive hordes of angry villagers with pitchforks, torches and clubs your way. : )
     
    Stomme poes, Apr 28, 2008 IP
  6. krame

    krame Guest

    Messages:
    74
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank You for your help
     
    krame, Apr 28, 2008 IP
  7. xtek

    xtek Well-Known Member

    Messages:
    943
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    130
    #7
    Yea alot of people want to steer clear of those sites! Here is a example.
     
    xtek, Apr 28, 2008 IP