In js, you can use the confirm method to delete the prompt information. The syntax format is "confirm (text content)". The confirm method is used to display a dialog box with a specified message and OK and Cancel buttons. If the user clicks the OK button, it returns true; if the user clicks the Cancel button, it returns false.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer. The
function deleteRecord(theId) { if(!confirm("您确定要删除该条记录吗?")) { return ; } document.location.href="delete.do?id="+theId; }
<a href="javascript:deleteRecord(<bean:write name="news" property="id"/>)">删除</a>
or
<a href="delete.do?id=1" οnclick="return confirm('确定删除?');">删除</a>
confirm() method is used to display a dialog box with the specified message and OK and Cancel buttons.
Syntax
confirm(message)
Parameters
message is the plain text (not HTML text) to be displayed in the dialog box that pops up on the window
If the user clicks the OK button, confirm() returns true. If the cancel button is clicked, confirm() returns false.
It will block all user input to the browser until the user clicks the OK button or the Cancel button to close the dialog box. When confirm() is called, execution of the JavaScript code is paused and the next statement is not executed until the user responds.
Tip: The text of the dialog button is immutable, so write your question or message carefully so that it is suitable for answering with confirm and cancel.
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to delete prompt information in javascript. For more information, please follow other related articles on the PHP Chinese website!