Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i need a custom confirmation box with ok , cancel button instead javascript confirm title on onbeforeunload event. please help me on this.
Posted
Comments
ZurdoDev 2-Apr-15 7:49am    
Sure. There are tons of examples online. Where are you stuck?
sherin.prajin 2-Apr-15 7:58am    
$(window).on('beforeunload', function () {

return 'Are you sure want to quit the application?.';
});

it is showing a confirmation box , but the header is 'Javascript Confirm'
instead of this i need custom box.
ZurdoDev 2-Apr-15 8:01am    
Then call a custom box inside the beforeunload function.

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Apr-15 11:56am    
5ed. I added additional information in my answer, please see.
—SA
Peter Leow 2-Apr-15 11:59am    
Thank you, Sergey.
In addition to Solution 1:

You can also find plenty of 3rd-party jQuery UI plug-ins collectively known as "modal popup", with different visual effects, such as transitions, and, notably, dimming of the rest of the screen: http://bit.ly/1DpajUJ.

The benefit of such solution is not just visual effects. This light-weight approach is always better for the user. JavaScript embedded alert and confirmation dialogs create a new window, which is inconvenient, not flexible, looks ugly.

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery,
http://jquery.com,
http://learn.jquery.com,
http://learn.jquery.com/using-jquery-core,
http://learn.jquery.com/about-jquery/how-jquery-works (start from here).

Remember that jQuery is designed with compatibility in mind.

—SA
 
Share this answer
 
Comments
Peter Leow 2-Apr-15 11:59am    
That make the solution complete, 5ed.
Sergey Alexandrovich Kryukov 2-Apr-15 12:02pm    
Thank you, Peter.
—SA

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



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