Click here to Skip to main content
15,885,031 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Am using __doPostBack at Browser close event its working in IE but not in Chrome.

Below is the JavaScript function i used :

XML
<script type="text/javascript" language="javascript">
    window.onbeforeunload = doUnload;
    function doUnload() {
        if ((window.event.clientX < 0) || (window.event.clientY < 0) || ((event.altKey == true) && (event.keyCode == 0))) {
            alert("hello IE");
            btncall();
        }
        else {
            if (!e) var e = window.event;
            {
                if (e) {
                    alert("hellooooooooooo Chromee...");
                    alert(document.getElementById("<%=lbtn_Logout.ClientID %>"));
                    var lbtnlogout = document.getElementById("<%=lbtn_Logout.ClientID %>");
                    __doPostBack(lbtnlogout, '');

                }
            }
        }
        function btncall() {
            debugger;
            var btn = document.getElementById("ctl00_lbtn_Logout");
            if (btn != null) {
                btn.click();
            }
        }
    }
</script>


<body onbeforeunload="doUnload()" onkeydown="return DisableEnterKey()">


its not working in Chrome can any one help me...
thanks in advance.
Posted
Updated 1-Dec-11 23:22pm
v2

1 solution

I believe you need to pass the server control id as the EventTarget and not the client id when you use __doPostBack call. Try changing the __doPostBack call as so...
C#
__doPostBack('lbtn_Logout', '')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900