Javascript alert on click, to continue..

Discussion in 'JavaScript' started by clasione, Sep 26, 2005.

  1. #1
    I've got an escorts catagory with some links on it....

    I want to use javascript to alert users that they should be 18 before continuing to the webpage...

    Does anyone have a javascript code that will do what I am looking for
     
    clasione, Sep 26, 2005 IP
  2. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <script type="text/javascript">
    <!--
    
    var answer = confirm ("Please click on OK to continue loading this page of paid sexual encounters, or CANCEL to be directed to Disney.")
    if (!answer)
    window.location="http://www.disney.com/"
    
    // -->
    </script>
    Code (markup):
     
    TheHoff, Sep 26, 2005 IP
  3. clasione

    clasione Notable Member

    Messages:
    2,362
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    228
    #3
    Very nice.... Let me give it a shot..... ;)
     
    clasione, Sep 27, 2005 IP
  4. clasione

    clasione Notable Member

    Messages:
    2,362
    Likes Received:
    158
    Best Answers:
    0
    Trophy Points:
    228
    #4
    ok - I saved that code, but it's not exactly what I was looking for....

    I want to assign something like that to a link on a page but not the entire page itself...

    Each escort link should open a box when clicked which you must okay to continue....

    Got anything else?
     
    clasione, Sep 27, 2005 IP
  5. TheHoff

    TheHoff Peon

    Messages:
    1,530
    Likes Received:
    130
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sure, I use it that way a lot when deleting items from a list.

    <script language="javascript">

    function verify(t,qs)
    {
    var agree=confirm("Are you sure you want to go to this page: '"+t+"'?");
    if (agree)
    location.href=qs ;

    }
    </script>

    <a href="#" onclick="verify('Escorts page','http://www.lotsahotgirls.com/');">Click here</a>
     
    TheHoff, Sep 27, 2005 IP