最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Refresh the page after click OK on alert box - Stack Overflow

matteradmin3PV0评论

In checkout page of my magento store, I need to clear some inputs when an alert box is showed and user press OK. Is possible to do that?

I have no control over the javascript alert. 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

I add location.reload(); because document.location.reload(true); not work on IE. Thanks everybody!

In checkout page of my magento store, I need to clear some inputs when an alert box is showed and user press OK. Is possible to do that?

I have no control over the javascript alert. 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

I add location.reload(); because document.location.reload(true); not work on IE. Thanks everybody!

Share Improve this question edited Jul 17, 2013 at 21:12 user2433958 asked Jul 17, 2013 at 20:14 user2433958user2433958 171 silver badge8 bronze badges 2
  • Could you clarify on which action magento shows alert? – Artem Latyshev Commented Jul 17, 2013 at 20:35
  • @ArtemLatyshev I am using a payment module with credit cards and need to modify it to be accepted by the credit card pany. When the customer inserts a number of invalid credit card and click on Place order button, the module displays a message (alert). – user2433958 Commented Jul 17, 2013 at 20:40
Add a ment  | 

3 Answers 3

Reset to default 3

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

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

Post a comment

comment list (0)

  1. No comments so far