Skip to content

Instantly share code, notes, and snippets.

@jvdi
Last active June 20, 2020 08:10
Show Gist options
  • Save jvdi/fb42aa9808684484ca1657377f8969ea to your computer and use it in GitHub Desktop.
Save jvdi/fb42aa9808684484ca1657377f8969ea to your computer and use it in GitHub Desktop.
Java script once alert
// Use function on page Without use return
function once_alert() {
// Create variable for check alert status in browser
var alertset = localStorage.getItem('alertset') || '';
// if value not set in browser > local storage - run alert
if (alertset != 'yes') {
// write alert message in "txt"
var txt = "Write once alert";
alert(txt);
localStorage.setItem('alertset','yes');
}
}
//# My Edition From :
//# Reference : https://stackoverflow.com/questions/24768067/display-alert-only-once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment