Strictly speaking, there is no such concept as "override" in JavaScript; even though what you do resembles OOP overriding, but JavaScript is not even close to OOP. Doing such things make little sense. Now, naturally, what happens to the argument depends on how the function is called. If your
window.confirm
object is called as the original function is supposed to be used, there is only one argument, so
onAction
simply does not exist. Naturally, you cannot call undefined object, and you cannot call a non-function object.
I would just forget the idea of
window.confirm
. It is hardly designed for quality refined code. For such purposes, you can better use flexible jQuery dialog:
https://jqueryui.com/dialog[
^].
Importantly, with such emulated modal behavior, you do everything on a single Web page, can keep consistent styles, and so on.
—SA