function clicked() {
if (confirm('You just clicked the button, click ok or cancel to refresh.')) {
yourformelement.submit();
location.reload();
} else {
return false;
}
}
<button class="center" type="submit" style="border: 0; background: transparent">
<img src="Playbutton.png" width="800" height="400" alt="submit" onclick="clicked();" />
</button>
当有人单击“确定”或“取消”时,我希望页面刷新
4条答案
按热度按时间p1iqtdky1#
2件事,首先将onclick处理程序放在按钮本身而不是图像上,其次在else语句中没有重载调用。
zy1mlcev2#
我想你不需要用“如果”这个词
我建议使用alert()仅显示消息。
zysjyyx43#
改变
location.reload();
到window.location.reload();
看看这能不能满足你的需要。oymdgrw74#
您的功能运行良好,但只需存储
confirm()
在变量中,然后在用户单击时进行检查ok
回来了true
当点击cancel
回来了false
所以如果你想确认你的工作cancel
及ok
您需要检查返回值,如下所示