Why is Post back not triggered when user navigates away from page, but triggered on close?
<p>I have the following code to detect user navigation or close.
The post back is triggered on close but not when navigated away.
If i place a alert message it is triggered at all times.</p>

<p>Oh and there is a timer on the page which is actually disabled after first tick. but there is always a post back triggers when navigating away with eventtarget timer. I think this may be because i have cleared cache for the previous page.</p>

<pre><code>&lt;script src="Scripts/jquery-1.4.4.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    $(window).bind("beforeunload", function () {
        alert("u r navigating away"); // this message gets triggered at all times.
        __doPostBack('callPostBack');
    });
&lt;/script&gt;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            string eventTarget = this.Request["__EVENTTARGET"];
            string eventArgument = this.Request["__EVENTARGUMENT"];

            if (eventTarget != String.Empty &amp;&amp; eventTarget == "callPostBack")
            {
                //do task
            }

        }
    }
</code></pre>

<p>Thanks in advance.</p>
