Skip to content

Overwrite native javascript function: confirm()

18. April 2012


You want to overwrite the native javascript function “confirm()”


Create a javascript function and include it in your html page

function confirm(msg, callback) {


Don’t do it like this:

window.confirm = function(msg, callback) {

Why? Because IE will not allow overwriting of native functions. (Only tested with IE9)


  • You will loose the typical alert()/confirm() behaviour, where all events in the browser are stopped.
  • In other words: The confirm() dialogs don’t exclude each other any more. They are displayed at the same time, this is due to the asynchronus nature of javascript.
  • Workarounds:
    • Use callback functions in your dialog handlers
    • Use the “Ok”-Button of your dialog handler to call subsequent dialogs



From → JS

Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: