1

I build website with popup. when user go to tab or exit button so the popup will show. My Question when user click the close button or submit form survey, so the popup will not show again when user go to tab or exit windows. this is my code below

<div class="box-download" id="showup-downloadbox" style="display:none;">
    <span id='close' onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;'>x</span>    
    <button type="submit" id="submitsurvey" class="submitsurvey" formtarget="_blank">SEND SURVEY</button>               
</div>

<script>
var mouseX = 0;
var mouseY = 0;
var popupCounter = 0;

document.addEventListener("mousemove", function(e) {
    mouseX = e.clientX;
    mouseY = e.clientY;
    document.getElementById("coordinates").innerHTML = "<br />X: " + e.clientX + "px<br />Y: " + e.clientY + "px";
});

$(document).mouseleave(function () {
    if (mouseY < 100) {
        if (popupCounter < 1) {
            $('#showup-downloadbox').delay(1000).show(0);
        }
        popupCounter ++;
    }
});
Yohanes Christian
  • 107
  • 1
  • 3
  • 10
  • You have no cookies here. Also don't use cookies to save state. Use localStorage – mplungjan Aug 20 '21 at 06:01
  • Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. Please first ***>>>[Search for related topics on SO](https://www.google.com/search?q=javascript+show+popup+only+once+localStorage+site:stackoverflow.com)<<<*** and if you get stuck, post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Aug 20 '21 at 06:05

0 Answers0