I want to close my current window in javascript and want a prompt alert to close or stay here when window is closed by me.
i have used onbeforeunload property of body tag.

Troy III commented: A working code has been given to you - you need to say "THANK YOU!" and mark your thread as "Solved!" -2

Recommended Answers

All 3 Replies

function closeEditorWarning(){
    return 'Are you sure?'
window.onbeforeunload = closeEditorWarning;

will do your thing!
;that is: the window will not close before prompting the client "do you wan't to close this tab \ window" ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.