[Resolved] Close Button on Section

Home Forums Support [Resolved] Close Button on Section

Home Forums Support Close Button on Section

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #837342
    Leon

    Hi Tom,

    I’ve given a section an id of “topBar” and when I click a button, that section will disappear. This is the JS code used:

    <script type="text/javascript">
    			document.getElementById("closeTopBar").onclick = function(){
    				document.getElementById("topBar").style.display = none;
    			}
    			
    		</script>

    The code works fine. However, when a user moves to another page, the section will show up again and it’s annoying.

    Question is: how to make it that when a user clicks the close button on any page, the section will not show up again on any page?

    (the section is a global section inserted by hook)

    #837900
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You would need to create a cookie, and then check for the existence of that cookie.

    This should help: https://github.com/js-cookie/js-cookie

    #839887
    Leon

    Thank you Tom. Will see if it works out for me.

    #840023
    Tom
    Lead Developer
    Lead Developer

    No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.