为什么不能有条件地弹窗
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> 鼠标经过事件 </title> <script type="text/javascript"> function message(){ passwd=document.getElementById("password").value; if(passwd=="") {confirm("请输入密码后,再单击确定!");} } </script> </head> <body> <form> 密码:<input name="password" type="password" id="password"> <input name="确定" type="button" value="确定" onmouseover="message()"/> </form> </body> </html>
我想让他先判断,如果输入框为空再弹窗,否则不弹窗,但是没有效果,执行上面的代码不弹窗。