Click here to Skip to main content
12,251,445 members (60,504 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi,

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

Below is the JavaScript function i used :

<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 1-Dec-11 23:21pm
Edited 1-Dec-11 23:22pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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...
__doPostBack('lbtn_Logout', '')
  Permalink  

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


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 2 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100