Is there a way to take some Javascript code that toggles divs and make it so when I return to that page, the same div is open that was when I left?

I am using this script:

```
(function() { // using an IIFE to prevent polluting the global namespace
    var opened_element = null;

    window.toggle_visibility = function(id) {
        var e = document.getElementById(id);
        if (opened_element && opened_element !== e) {
            opened_element.style.display = 'none';
        }
        if(e.style.display == 'block') {
            e.style.display = 'none';
        } else {
            e.style.display = 'block';
        }
        opened_element = e;
    };
}());

```