+ 1
How can I display a one time alert?
I am a thirteen years old programmer and android apps developer. I started coding at the age of twelve. Now I have been creating apps and my own blogs. So, I want to know if there is a way through which I can display an one time alert in my app using JavaScript. I have done it by adding the code: alert('Hello world'); But every time the users visit the app they see this text. So I want to get your help that I may show this text only for the first time.
2 Antworten
+ 3
Try this using local storage to store status
const greeting = 'greeting';
const greetingText = 'Hello world';
if(!localStorage.getItem(greeting)) {
localStorage.setItem(greeting, greetingText);
alert(greetingText);
}
+ 1
Calvin I'm greatly thankful to you for your help. You are lovely. Thanks for your help. Stay home, Stay safe and Stay Genius 😊😊☺️