Forum Moderators: open
I'm producing a web interface to administrate a database, and have a series of links to edit/delete records.
Is there a way (with JS) to only navigate through a link if a user confirms their intention with an alert box, or some other condition for that matter?
Alternatively, can a change of page be initiated purely by a JS command?
Thanks for your help.
<a href="javascript:void(mycondition('myurl.htm'))">my link</a> Refers to a function that pops up your confirmation window:
<script ... >
function mycondition(loca) {
// pops up a "prompt" window
activateLink=prompt("Do you really want to go?");
if (activateLink) {
// they clicked "OK", so off they go
top.location.href=loca;
}
}
</script> And yes, you can redirect a visitor based exclusively on a Javascript instruction, but I'm not sure what use you have for it.