How to write a script that does not allow the modal window to pop up again if the user has followed the specified link?

  • 0
    After the beginning of the meeting, the user should receive a notification in the form of a modal about its beginning. He can go by clicking on the corresponding button or cancel. How to make sure that after switching to a meeting, the modal no longer pops up, and when you click the "cancel" button, it pops up 2 more times?

    buttons:
    const modalDelete = document.getElementById ('modalTransit');
    const modalRepeat = document.getElementById ('modalCancel');

    function checkTime (date) {

    localStorage.setItem ('number', Date.now ()); // save the current time in LocalStorage
    const conferenceTime = Date.parse (date); // meeting start time
    if ((conferenceTime - localStorage.getItem ('number')) & lt; 0) {
    showModal (resp.url); // meeting started - modal pops up

    }
    }

    I tried to attach event handlers to buttons and delete time from LocalStorage after clicking - it didn't work. I would be grateful for your help
    JavaScript Eliana Melton, Sep 7, 2019

  • 1 Answers
  • 0
    I would take from the function
    const conferenceTime = Date.parse(date); // время начала собрания


    Added counter for modals bubbling:

    let counterModal = 0

    And the function would be wrapped in an interval:

    let interval = setInterval(function (){
    if(cunterModal <3){
    //показать модалку
    counterModal++
    } else {
    clearInterval(interval)
    }
    },60000)


    If the user accepts the meeting, it will add +3 to the counter. Or add a condition to the if. Well, in short further as you like.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!