How to detect the X button in IE8

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chowdhury
    New Member
    • Jun 2007
    • 5

    #1

    How to detect the X button in IE8

    Dear Sir,
    I am trying to catch the close button event(X) at internet explorer 8.
    i trying with follwoing code.but in that case i can detect tab button while it's close(X) is clicked.

    Code:
    function closeIt(){
        
    if( !event) { event = window.event ; } 
    
     if (event.clientY < 0)
     			{
             		 //event.returnValue = 'Are you sure you want to Quit?'
    		 }
       }
    
    <body   onBeforeUnload="closeIt()">
    </body>
    Regards,
    Faruk Chowdhury.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    if its just for an alert then you might try:
    Code:
    window.onbeforeunload = function() {
        alert('foo')
    }

    Comment

    • pradeepkr13
      New Member
      • Aug 2010
      • 43

      #3
      this doesn't work consistently in IE and Mozilla

      Comment

      • farukcse
        New Member
        • Nov 2007
        • 52

        #4
        Thanks a lot....
        it works fine with IE ...

        Comment

        Working...