There is a site with a block layout. Blocks: header, navigation, content, menu, footer. There is a navigation bar with buttons (navigation). When you click on the button information is loaded into the content block.
How to make it so that after logging in to the site, the Login button changes to the Exit button. Only jacascript is available, which I do not know.
As I think, it is necessary to check js with the user’s cookies, and if there is no navigation block (Home, account, website, Logout), and if it has expired, then navigation2 block (Home, account, website, Log in) .
I set the blocks as:
<div id="navigation" style="display:none"> <div id="navigation1" style="display:none"> css:
#navigation { display: block; background: #a2a2a2; width: 900px; height: 40px; } #navigation1 { display: block; background: #a2a2a2; width: 900px; height: 40px; } js:
function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } myVar = getCookie("la2user"); if (myVar !== null) {document.getElementById('navigation1').style.display = 'block'; } else {document.getElementById('navigation').style.display = 'block'; } I try so. It does not work, although if after writing {alert(myVar)} then the cookie displays.