Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在html中嵌入javascript函数_Javascript_Onsubmit - Fatal编程技术网

在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的环境中使用。