iconicCreator Posted June 22, 2009 Share Posted June 22, 2009 I'm totally new to Javascript and really knows nothing. I have manage to create a Javascript style switcher with the help of many good people on this and other forum. This script causes the style sheets attached to my web page to change based on the user selection. When the user click a link or tab, the page changes styles. There are two style sheets, default and zoom. This is the function that process the style switching. var mystylesheets=["default", "zoom"] var cursheet=1 function rotateStyle(){ chooseStyle(mystylesheets[cursheet], 60) cursheet=(cursheet<mystylesheets.length-1)? cursheet+1 : 0 var obj = document.getElementById('mylink'); if(obj.innerHTML == 'default') obj.innerHTML = 'zoom'; else obj.innerHTML = 'default'; } Here is the link the user can click to switch style sheets. <a id="mylink" href="javascript:rotateStyle();">default</a> When this link is click, the style sheet changes. What this code also does is change the text or label on the link when the user click on it. So when the user click on the tab/link - the text changes to zoom or default. This helps the user know what style sheet they have selected. The problem is this. I need a way to make the text or label stay on the tab/link even when the page is refreshed. Because when the page is refreshed, the label/text changes to default, even if the user is viewing in the zoom mode. I need to know how I can set cookies for this. I have searched Google but found nothing I can understand. How do I set cookies so that the label stay on the tab even when the page is refreshed. Any help will be greatly appreciated. Thanks everyone. IC Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 22, 2009 Share Posted June 22, 2009 Here is info on reading/writing cookies with JavaScript: http://www.w3schools.com/JS/js_cookies.asp Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted June 23, 2009 Author Share Posted June 23, 2009 Here is info on reading/writing cookies with JavaScript: http://www.w3schools.com/JS/js_cookies.asp I'm just confused because I'm not trying to set cookies for a user name, it appears everything I read regarding cookies talks about getting user information for displaying. I just want the page to remember the text on the label so that it can remain when the page is refreshed. Thanks for the responds. IC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.