Ashly Thompson
10-17-2011, 08:09 AM
Please someone help me.
I have created these cookies and want to resize text with two buttons. But I am wrong somewhere and can't think any more. text size is increasing and decreasing. but when I close the page and reopen it the default font is there.I want my preferred font size to be saved as cookies. Please help me.
thanks
this is my code..
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function resizeText(multiplier) {
if (document.body.style.fontSize== ""){
document.body.style.fontSize ="1.0em";
}
document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
}
function setCookie (name) {
var Cookie
var resizetext
resizetext=bodyElement.value;
createCookie("resizetext",tresizetext, 365);
return false;
}
<script>
<lable> This text need to be big and small </label><br />
<Input type="button" value= "big text" onclick="resizeText(1)" />
<input type="button" value= "Small text"onclick="resizeText(-1)" />
I have created these cookies and want to resize text with two buttons. But I am wrong somewhere and can't think any more. text size is increasing and decreasing. but when I close the page and reopen it the default font is there.I want my preferred font size to be saved as cookies. Please help me.
thanks
this is my code..
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function resizeText(multiplier) {
if (document.body.style.fontSize== ""){
document.body.style.fontSize ="1.0em";
}
document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
}
function setCookie (name) {
var Cookie
var resizetext
resizetext=bodyElement.value;
createCookie("resizetext",tresizetext, 365);
return false;
}
<script>
<lable> This text need to be big and small </label><br />
<Input type="button" value= "big text" onclick="resizeText(1)" />
<input type="button" value= "Small text"onclick="resizeText(-1)" />