In many pages have this effect, when clicked on a button or other objects will pop up a prompt box, if click OK to continue to execute the established program, if click Cancel will cancel continue execution, the code example is as follows:
The above code, when clicked on the link will pop up a prompt box, if click OK will visit Ant Tribe home page, otherwise will not visit. The core of this functionality is the use of confirm (), which is the text content of the prompt box. Here is a brief introduction to the principle of the above code:
When clicking on a link, the onclick event handler that is bound to a element is called.
Two. In the event handler function, the Confirm () returns true when clicked on the OK button, and the click Cancellation returns False, then the IF statement chooses whether to execute an if statement or an else statement based on the return value of confirm ().
The above mentioned is the entire content of this article, I hope you can enjoy.