简体   繁体   English

单击警报框上的“确定”后刷新页面

[英]Refresh the page after click OK on alert box

In checkout page of my magento store, I need to clear some inputs when an alert box is showed and user press OK. 在我的magento商店的结帐页面中,当显示警告框并且用户按OK时,我需要清除一些输入。 Is possible to do that? 有可能做到吗?

I have no control over the javascript alert. 我无法控制javascript警报。 So I think in a script that detect an alert with a specific message and clear inputs when button of that alert is clicked. 因此,我认为在一个脚本中,该脚本可检测带有特定消息的警报,并在单击该警报的按钮时清除输入。

UPDATE 更新

Fixed! 固定!

file: opcheckout.js line: 888 文件:opcheckout.js行:888

I add location.reload(); 我添加location.reload(); because document.location.reload(true); 因为document.location.reload(true); not work on IE. 在IE上无法使用。 Thanks everybody! 谢谢大家!

Probably try overriding default alert and write a custom function like below, 可能尝试覆盖默认警报并编写如下的自定义函数,

var c_alert = alert;

window.alert = function (str) { //override default alert
    c_alert(str + ' my message');
    location.reload();
    //or write code to clear input fields here
}

//below seems to be triggered from somewhere where you don't have control.
alert('test');

Javascript Java脚本

if(confirm('your confirmation text')){
document.location.reload(true);
}

Make it refresh after the alert. 使其在警报后刷新。 The javascript code shouldn't execute before the alert is gone 警报消失之前,不应执行javascript代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM