0

Hi I'm wondering if it is possible to show an Alert Confirm Prompt only once on and after selecting the OK prompt.

I'm using this as an age verifier I want to stop the dialogue popping up each time the website is visited after the 'OK' is selected.

This is what I'm working with.

<!--

var answer = confirm ("By joining this website you confirm to be 18 or older. Press 'OK' to confirm or 'Cancel' to leave.")
if (!answer)
window.location="http://www.google.com/"

// -->

Thanks

troxie
  • 21
  • 6
  • 3
    Use a cookie or localstorage. How were you even able to ask this? – mplungjan Sep 03 '16 at 15:05
  • The article refereed does not help me. I'm working with two prompts within the pop up message 'OK' and 'Cancel' the method shown here shows a single pop up message with one prompt. – troxie Sep 03 '16 at 15:20
  • The use of localStorage does not depend on number of prompts. You have not given enough details to see what is not solved by tweaking the answer in the duplicate. Update your question please – mplungjan Sep 03 '16 at 15:53
  • Thank you for this. I'm a beginner at JavaScript I'm not sure how I'm able to implement this in with the code shown in my post above. – troxie Sep 03 '16 at 16:18
  • It replaces it... There was a typo - here is a better version: https://jsfiddle.net/mplungjan/0rps2cc6/ `if (localStorage.getItem("seen")) { console.log("seen"); } else if (confirm("old enough?")) { localStorage.setItem("seen", "yes"); } else location.replace("http://othersite.com");` – mplungjan Sep 03 '16 at 16:33
  • Thank you for this – troxie Sep 03 '16 at 16:43

0 Answers0