I am displaying a confirm box in my app. When the user clicks on Okay
, I close the window
when user clicks on Cancel
, I want to do nothing but stay on the same page.
What should I write in place of DO_NOTHING?
<a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():DO_NOTHING')">Close the application ?</a>
If I keep it empty it does not work. If I write any random string it works but displays string undefined
error.
JavaScript has two values which mean "nothing", undefined and null . undefined has a much stronger "nothing" meaning than null because it is the default value of every variable. No variable can be null unless it is set to null , but variables are undefined by default.
It's a new feature that introduced in ES6 and is called arrow function. The left part denotes the input of a function and the right part the output of that function.
A function that does nothing (yet) is an indicator that something should be done, but hasn't been implemented yet. Follow this answer to receive notifications. answered Jun 27, 2016 at 13:42. Ivan Rubinson.
Try using void(0)
<a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():void(0)')">Close the application ?</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With