Jquery modal dialog on all hyperlink clicks in a page
<p>In my project, I have a page where I need to show a modal dialog on the click of all the hyperlinks.</p>

<p>The popup has two buttons Images "Continue" and "GoBack". I wrote some jquery which I found on this Stackoverflow website. But there is a problem with code.</p>

<p>Suppose I have 5 hyperlinks in this page. When I  click on the first link its opening the dialog and when I click on continue its opening the link properly.</p>

<p>But when I click on the second link its opening again the first link and the second link 
two separate windows, Which is wrong it supposed to open only second link.</p>

<p>When I click on the third link again its opening first,second and third links in 3 windows.</p>

<p>I guess I am doing a small mistake in my code. If anyone help me fixing this I really appreciate.</p>

<p>Thanks for your help in advance. Here is my jquery code:</p>

<pre><code>&lt;script type="text/javascript"&gt;
&lt;!-- Loading Modal Dialog Popup--&gt;
$(document).ready(function() {
    //  $(".leaving-the-site-container").hide(); 
    $(".linkdialog").click(function(e){
        e.preventDefault();                            
        var targetUrl = $(this).attr("href");                     
        alert(targetUrl);

        $(".leaving-the-site-container").dialog({        
            width:452,
            // autoOpen:false,
            // height:225,
            modal:true,
            closeOnEscape:false,
            draggable:false,
            scrollbars:false,
            position: ["center", 240]
        });                                                      

        $("#btnContinue").click(function(){                            
            window.open(targetUrl);
            $(".leaving-the-site-container").dialog("close");                                                                         
        }); 
        $("#btnTakeMeBack").click(function(){
            $(".leaving-the-site-container").dialog("close");
        });
    });
});
&lt;/script&gt;
</code></pre>
