<script>alert('Hai Jangan lupa klik tombol Refresh!(Ok Untuk Lanjutkan)');</script>
when I refresh my website the alert notification keeps popping up, I only want the alert to appear only once when the web is first opened
<script>alert('Hai Jangan lupa klik tombol Refresh!(Ok Untuk Lanjutkan)');</script>
when I refresh my website the alert notification keeps popping up, I only want the alert to appear only once when the web is first opened
A simple flag is what you need.
if(window.localStorage.getItem("visited")){
alert("something");
window.localStorage.setItem("visited", true)
}
Depending on what you want to setup the scope of the storage, you can checkout localStorage, sessionStorage or cookies What is the difference between localStorage, sessionStorage, session and cookies?
You can use localStorage and check if the alert has already popup.
if (localStorage.getItem('__isAlert') !== "show") {
localStorage.setItem("__isAlert", "show");
alert("Hai Jangan lupa klik tombol Refresh!(Ok Untuk Lanjutkan");
}