Load a window only once after reloading the site in Asp.net C#

Asked

Viewed 83 times

0

Having this window esta janela when accessing a website for the first time, how do I only appear once even after reloading the website or the user goes back to the home page and does not reappear this?

<input type="radio" id="rd">
    <div class="bg">
        <div class="box">
            <p class="p1">Bem-vindo</p>
            <p class="p1">á</p>
            <p class="p1">DOMO® Portugal</p>
            <p class="p2">Tornamos o seu sonho realidade</p>
            <label for="rd">Visitar</label>
        </div>
    </div>

I’ve been researching something about localstorage but I don’t understand how it’s done.

EDIT:

I have already found the solution to this question: https://stackoverflow.com/questions/30899415/show-a-div-only-once-per-time-the-user-is-on-the-site

1 answer

0

You can use the sessionstorage, it will have value until the user closes the browser, after that it will be destroyed

    $(function() {  
        var deveExibirModal = sessionStorage.getItem('deveExibirModal');        
        if(deveExibirModal != undefined && deveExibirModal != "nao"{ 
            $( "#dialog-modal" ).dialog({
                height: 140,
                close: function( event, ui ) {
                    sessionStorage.setItem('deveExibirModal', 'nao');               
                }
            });
        }
    });

Now if you want to control it in a different way there’s the localstorage its value will only be destroyed by code or if the user cleans or uninstalls the browser

$(function() {  

    var dataVencimento = localStorage.getItem('dataVencimento');

    if(dataVencimento < hoje)
    {
        localStorage.removeItem("deveExibirModal");
        localStorage.removeItem("dataVencimento");
    }       

    var deveExibirModal = localStorage.getItem('deveExibirModal');

    if(deveExibirModal != undefined && deveExibirModal != "nao"{ 
        $( "#dialog-modal" ).dialog({
            height: 140,
            close: function( event, ui ) {
                localStorage.setItem('deveExibirModal', 'nao');
                localStorage.setItem('dataVencimento', 'sua_data');
            }
        });
    }
});

You can read more on documentation

  • It might be a good idea.. except I don’t own any Modal.. Everything I have is in the code I put in the question.. That script I put I picked up another question but it doesn’t work in my project

  • It doesn’t make sense for you to ask something, to add a code that’s not yours.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.