Would it be possible to have dynamic font size / family where the user select it's prefered size and family while this preference will be used throughout the entire site.
I know it can (partially) as i have one that uses Javascript and cookies to store the users preference.
But what i can't get to work is having the cookie store both the prefered size and font family.
Javascript code:
<script type="text/javascript" language="JavaScript1.2"> path='/'; function SetCookie (value) { expires = new Date(); expires.setTime(expires.getTime() + 50000); document.cookie = "stylesheet=" + escape (value) + "; expires=" + expires.toGMTString() +"; path=" +path; location.reload(); } function DeleteCookie () { expired = new Date(); expired.setTime (expired.getTime() - 1); document.cookie = "stylesheet=" + "; expires=" + expired.toGMTString() +"; path=" +path; location.reload(); } </script> <script language="javascript1.2" src="css/selector.js"></script> <script> function doSel(obj) { for (i = 1; i < obj.length; i++) if (obj[i].selected == true) eval(obj[i].value); } </script>
Body code:
<form> <p class="control_block"><strong>LetterGrootte:</strong></p> <select name="jsSelList" onclick="doSel(this)" style="width:140px; margin:10px;"> <option value="DeleteCookie('')"></option> <option value="SetCookie('css/fontSize01')">Normal</option> <option value="SetCookie('css/fontSize02')">Large</option> <option value="SetCookie('css/fontSize03')">Extra Large</option> </select> <p class="control_block"><strong>LetterType:</strong></p> <select name="jsSelList" onclick="doSel(this)" style="width:140px; margin:10px;"> <option value="SetCookie('css/fontType01')">Arial</option> <option value="SetCookie('css/fontType02')">Times</option> <option value="SetCookie('css/fontType03')">Verdana</option> </select> </form>
The fontSize01 - fontSize03 are 3 seperate .css files
to define what text want to resize and how big ( in percentages)
and fontType01 - fontType03 are 3 seperate .css files
which defines the family.
But how in the world can i store 2 prefered variables ?
With 2 cookies ?
Big thank you in advance..
Dynamic font size / font family possibility
Hi Chappo,
You can store more then one value in a cookie using specific character to separate the values then split the values when you need to use them.
Try searching google http://www.google.com/search?q=cookie+array
Hope that helps
Dynamic font size / font family possibility
Knowing that i'm a total Javascript noob , i'll try to find some tutorials/examples on it.
Thanks
Dynamic font size / font family possibility
Another thought along the same lines is to create a PHP class and store the info in the session variables rather than Javascript. I've found this to be quite helpful, and in some situations, I like the speed of the server-side compilation better, too.