I have this code that shows alert when it\'s 30 minutes before event in calendar but I want to show it only once when user comes to page (in that 30min). Now it shows on eve
You can use localStorage (not compatible with older browsers):
<script type="text/javascript">
var alerted = localStorage.getItem('alerted') || '';
if (alerted != 'yes') {
alert("My alert.");
localStorage.setItem('alerted','yes');
}
</script>
Or you can use cookies, give a look to this answer for a full example code: https://stackoverflow.com/a/21567127/3625883
Set a cookie when you show the alert. Then, if the cookie is set, you will know not to show the alert again. If it is not set, you know that you haven't shown the alert yet and should do so now.
You can read about setting cookies in JavaScript here.
You have to use cookies or localStorage or sessionStorage to do this!
See the following link on localStorage: http://www.w3schools.com/html/html5_webstorage.asp
or
http://www.webdesignerdepot.com/2013/04/how-to-use-local-storage-for-javascript/