code to close a window..

Hi

Initially,the user is not permitted to close his/her window.
can anyone plz tell me some way to allow the user to close the window..ie,in some
event,i should make the user to close the window by asking a confirmation message
"Do u want to exit?yes,No"...Can anybody plz suggest some idea about the event in
which i can handle this.
can anyone plz help me with the javascript or asp.net code to close the window too..

Any suggestions are greatly appreciated..
Thanks in advance..

Regards
blob

Comments

  • In the onlick event of a button ...

    [code]

    window.onload = function(){
    var myCloseBtn = document.getElementById('myCloseBtn');

    if(myCloseBtn)
    myCloseBtn.onclick = function(){
    if(window.confirm('Are you sure?'))
    window.close();
    }
    }

    [/code]

    This entails your close button has an id of 'myCloseBtn'. Also, place this code near the top of your page, maybe under the BODY tag.

    Also, I always use the unobstrusive way of assigning event handlers, by setting it through code, rather than placing an onclick attribute on the HTML control.

    : Hi
    :
    : Initially,the user is not permitted to close his/her window.
    : can anyone plz tell me some way to allow the user to close the window..ie,in some
    : event,i should make the user to close the window by asking a confirmation message
    : "Do u want to exit?yes,No"...Can anybody plz suggest some idea about the event in
    : which i can handle this.
    : can anyone plz help me with the javascript or asp.net code to close the window too..
    :
    : Any suggestions are greatly appreciated..
    : Thanks in advance..
    :
    : Regards
    : blob
    :

  • hi,

    You may try window.close event after the msg appears....


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories