Provato coi cookies?
codice:<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Esempio</title> <script type="text/javascript"> function showBlockDivs (bReverse) { var oDivList = document.getElementsByName("blockDiv"), bShow = document.cookie.replace(/(?:(?:^|.*;\s*)show\-block\-divs\s*\=\s*((?:[^;](?!;))*[^;]?).*)|.*/, "$1") === "true"; if (bReverse === true) { bShow = !bShow; document.cookie = "show-block-divs=" + bShow.toString() + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"; } for (var nItem = 0; nItem < oDivList.length; nItem++){ bShow ? oDivList[nItem].style.removeProperty("display") : oDivList[nItem].style.setProperty("display", "none"); } document.getElementById("switch-btn").value = bShow ? "Ignora" : "Visualizza"; return bShow; } onload = showBlockDivs; </script> </head> <body> <input id="switch-btn" type="button" onclick="showBlockDivs(true);" /> <div name="blockDiv">Testo di esempio 1</div> <div>Testo di esempio 2</div> <div name="blockDiv">Testo di esempio 3</div> </body> </html>


Rispondi quotando