Reputation: 3777
I have an existing icon that performs a javascript reload of the page. How do I add an alert with an ok or cancel prior to executing the reload?
<a href="#" onClick="window.location.reload()"><img src="img/reload.png" alt="Reset" name="Reset" width="32" height="32" align="middle" id="Reset" /></a>
Upvotes: 0
Views: 239
Reputation: 192
Well if you do a little bit of googling, it is quite simple to find. http://www.w3schools.com/js/js_popup.asp
confirm("sometext");
if (confirm("Press a button"))
{
x="You pressed OK!";
window.location.reload();
}
else
{
x="You pressed Cancel!";
}
This should help.
Upvotes: 1