在html中嵌入javascript函数
我想在提交表单之前使用一个确认框供用户检查。我在脚本中使用以下表单标记:在html中嵌入javascript函数,javascript,onsubmit,Javascript,Onsubmit,我想在提交表单之前使用一个确认框供用户检查。我在脚本中使用以下表单标记: <form action="delete.php" method="POST" target="_blank" onsubmit="return confirm(\"Are you sure you want to delete it from the database?\");"> 但它不工作,在我点击“提交”按钮后,“delete.php”将被执行。谁能帮我找出哪里出了错?我想知道是不是因为这个“co
<form action="delete.php" method="POST" target="_blank" onsubmit="return confirm(\"Are you sure you want to delete it from the database?\");">
但它不工作,在我点击“提交”按钮后,“delete.php”将被执行。谁能帮我找出哪里出了错?我想知道是不是因为这个“confirm”函数是某种内联样式,我需要在
标记中进行一些引用?谢谢
onsubmit="return confirm('Are you sure you want to delete it from the database?');"
经过测试,效果良好。我认为你不能在标签中转义这样的字符。啊,我不知道我怎么会忽略转义字符。转义字符将在html中创建并抛出错误。转义字符只能在仅JS的环境中使用。