In JavaScript, there is no such concept as "overriding". This is not an object-oriented language. No wonder, if you don't understand what you are doing, something may not work the way you illusions suggest you. :-)
But yes, assignment to the function object
window.open
resembles "overriding" in some aspects. But the code after "
window.open =
" is full of nonsense. You create It's enough to look at the first problem. Essentially, this function does nothing. You create some other function object inside the handler and, by some weird reason, return this object from the outer function. You don't show any code calling
window.open
. You don't show any code calling the returned inner function. This is not how original
window.open
function works. It is supposed to actually create a new instance of a browser window and show it, not to return a function object which is never called. It is supposed to return the reference to a new
window
object, not to the function object:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open[
^].
Please don't ask "what to do?" You may get some more help only if you explain what did you want to achieve.
—SA