-2

I have a simple confirm() when a user clicks a link or a button but regardless of whether they answer yes or cancel, it seems to cancel the entire navigation.

when I remove the confirm() code the navigation happens fine.

is there anyway around this? I need to confirm with the user whenever they click on any element on the page but when the confirm comes up for link or button it seems to cancel the navigation from happening.

user299709
  • 4,922
  • 10
  • 56
  • 88

1 Answers1

-1
<script>
   if(confirm('do you wish to proceed?'))
   {
      //proceed with navigation
   }
   else
   {
      //cancel navigation
   }
</script>
NaijaProgrammer
  • 2,892
  • 2
  • 24
  • 33
  • 1
    The code you show will display `do you wish to proceed?` when the page/script is loaded, but not at a `click` on a link. Beside that I'm pretty sure the OP has problems with the `//proceed with navigation` part. – t.niese Mar 19 '15 at 08:53