我在我的应用程序中显示一个确认框.当用户点击时Okay,我
在用户点击时关闭窗口Cancel,我想什么也不做但只能停留在同一页面上.
我应该写什么代替DO_NOTHING?
<a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():DO_NOTHING')">Close the application ?</a>
Run Code Online (Sandbox Code Playgroud)
如果我把它保持为空它就行不通.如果我写任何随机字符串它可以工作,但显示string undefined错误.
Mat*_*ean 23
尝试使用 void(0)
<a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():void(0)')">Close the application ?</a>
Run Code Online (Sandbox Code Playgroud)
Sha*_*ard 13
请改为:
onclick="if (confirm('Do you wan to close the application ?')) window.close();"
Run Code Online (Sandbox Code Playgroud)
没有意义,x?y:z如果你不打算"完全"使用它.
尝试return false;或null
// What should I write in place of DO_NOTHING
<a href="#" onclick="confirm('Do you wan to close the application ?')?window.close():return false')">Close the application ?</a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
56984 次 |
| 最近记录: |