I know this should be simple...help!

Discussion in 'JavaScript' started by bytenannie, Apr 18, 2008.

  1. #1
    I need to reproduce the confirmation window shown in the following site. It is for following an outside link.
    http://www.cunamutual.com/cmg/home/ (just click on any outside link to see the window).
    This should be simple...HAH!
    Any help would be greatly appreciated!!
     
    bytenannie, Apr 18, 2008 IP
  2. eTechDude.com

    eTechDude.com Member

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #2
    function confirmation() {
    	var answer = confirm("Leave mywebsite.com??")
    	if (answer){
    		return true;
    	}
    	else{
    		alert("Thanks for sticking around!")
    	}
    }
    Code (markup):
    onclick="confirmation()"
    Code (markup):
     
    eTechDude.com, Apr 18, 2008 IP
  3. bytenannie

    bytenannie Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you, but I need to attach this to a link...they click the link then they get the window. then depending on the answer, they are either redirected to the outside link stay on the page they were on originally....
    any thoughts??
     
    bytenannie, Apr 18, 2008 IP
  4. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <a href="link here" onclick="confirmation()">Text here</a>

    That should do the trick I think.
     
    Dondon2d, Apr 18, 2008 IP
  5. bytenannie

    bytenannie Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank you...I will try that tomorrow...
     
    bytenannie, Apr 18, 2008 IP
  6. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You forgot the "return false;" if they don't confirm.

    function confirmation() {
    var answer = confirm("Leave mywebsite.com??")
    if (answer){
    return true;
    }
    else{
    alert("Thanks for sticking around!")
    return false;
    }
    }
     
    GreatMetro, Apr 19, 2008 IP
  7. bytenannie

    bytenannie Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I am still doing something wrong. I am VERY new to this and apparantly very confused!
    How do I join all the info given above together so it works??? Every way I have tried doesn't work....UGH

    and I have been unable to find an existing script that works...
    Thank you to all who have attempted to help!!
     
    bytenannie, Apr 21, 2008 IP