在html中嵌入javascript函数

embed javascript function in html

本文关键字:javascript 函数 html      更新时间:2023-09-26

我想使用一个确认框供用户在提交表单之前检查。我在脚本中使用以下表单标签:

<form action="delete.php" method="POST" target="_blank" onsubmit="return confirm('"Are you sure you want to delete it from the database?'");">

但是它不工作,在我点击"提交"按钮后,"delete.php"将被执行。谁能告诉我哪里出错了?我想知道是不是因为这个"确认"函数是某种内联样式,我需要在<head>标签中做一些参考?谢谢!

onsubmit="return confirm('Are you sure you want to delete it from the database?');"

已测试,并且工作正常。我不认为你可以在标签中转义这样的字符