Hello,
I use the below script to allow visitors to my page to increase / decrease the font size (or restore the font size to its default setting).
Does anybody know how I could get each page to retain the increased/decreased font size of the previous page? Currently, when a visitor adjusts the font size and goes to another page the font size returns to the default size, meaning that the visitor then has to re-adjust the font size again for each page they visit. It would be nice if once the visitor adjusts the page size on one page and then goes to another page, that other pager would automatically appear in the adjusted font size. Thank you, Chris
function changeFontSize(objId, doIncreaseSize) {
var currentSize = 0, obj = document.getElementById(objId), newVal = 0, limitMax = 1.7, limitMin = 0.9, unit = 0.1;
if(!obj){
return false;
}
currentSize = parseFloat( obj.style.fontSize );
if (!obj.originalSize) { obj.originalSize = currentSize; }
if(doIncreaseSize){
unit = -unit;
}
newVal = currentSize - unit;
if(limitMax >= newVal && limitMin <= newVal){
obj.style.fontSize = newVal + "em";
}
return true;
}
function resetDefaultSize(objId) {
var obj = document.getElementById(objId);
if(!obj){
return false;
}
if (obj.originalSize) { obj.style.fontSize = obj.originalSize + "em"; }
return true;
}
And the HTML:
INCREASE: <href="#" onclick="changeFontSize('mydiv', true); return false;">
DECREASE: href="#" onclick="changeFontSize('mydiv'); return false;">
RESET TO DEFAULT: <href="#" onclick="resetDefaultSize('mydiv'); return false;">