help with $("a").click(function(){

help with $("a").click(function(){

 

 Hi,

I hope someone can help me out but this is the questions.

I have a list of sites that are approved, all other sites will need to prompt the user that they are moving outside the "approved" sites

Now I posted this question a while back and I got a response that does what I want but with one problem, it still takes the user to the page even if they say cancel. Below is my code.

   
  1.  <a href="#">link one</a>
    <a href="http://yahoo.com">link two</a>
    <a href="http://msn.com">link three</a>
    <script>
    $("a").click(function(){
    var Current=window.location;
    var href = $(this).attr("href");

    var r=confirm("You are about to leave the website are you sure you want to do this?");
    if (r==true)
    {
    window.location =href;

    }
    else
    {
    window.stop();
    }

    });

    </script>





















Now I have tried the window.stop as you can see and it does not stop the page from loading.

So in this example I have say 3 links and if someone clicks cancel it should stop and not go anyware but what happens is it still goes to the link.



Anyhow I hope someone can point me in the right direction.

Thanks!

Mike.