trigger a click event if confirmation message
<p>Here is my code :</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function () {
    $(window).bind('beforeunload', function () {
        alert("unload");
        if (closeIt())
            $("#&lt;%=Button1.ClientID %&gt;").trigger('click');

    });
    function closeIt() {
        var ans = confirm("save current layout ?");
        if (ans) return true;

    }
});
&lt;/script&gt; 
&lt;asp:Button ID="Button1" runat="server" OnClick="btnSaveState_Click" style="display:none;" /&gt;
</code></pre>

<p>the new problem is that the confirm message is displayed twice on firefox and non of chrome</p>
