Local storage javascript

How to use local storage javascript:

<style>
    * {
        margin: 0;
        padding: 0;
        font-family: Arial, Helvetica, sans-serif;
    }
    .fixedFooterCookies {
        position: fixed;
        bottom: 0;
        border: 1px solid #ccc;
        padding: 10px;
        text-align: center;
        width: 100%;
    }
</style>
Local storage first page.
    <div class="fixedFooterCookies">Footer
        <button id="clickCookiesFooter">Click me</button>
    </div>
    <script>
        var clickContainer = document.getElementsByClassName('fixedFooterCookies')[0];
        //alert(clickContainer);
        var clickFunc = document.getElementById('clickCookiesFooter');

        clickFunc.onclick = function () {
            localStorage.setItem("cookieBox", "1");
            clickContainer.style.display = 'none';
        }
        var localSto = localStorage.getItem("cookieBox");
        if (localSto == 1) {
            clickContainer.style.display = 'none';
        } else {
            clickContainer.style.display = 'block';
        }
    </script>


No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.