Hi All
i am trying to change the font of my web page with user preference.i made use of cookie to get the user's preference, so that the font size selected will remain for the next session. i am changing the style sheet with the cookie set, The below shown is my code
[CODE=javascript]function readCookie(name ) {
alert("i am Reading the cookies");
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(name EQ) == 0)
return c.substring(nam eEQ.length,c.le ngth);
}
}
return null;
}
function setFont(c_value )
{
switch(c_value)
{
case 'big':
var navNam = navigator.appNa me;
var navVer= parseFloat(navi gator.appVersio n);
if (navNam.indexOf ('Microsoft') != -1 ) {
//IE
document.write( '<link rel="stylesheet " type="text/css" href="/imagesvariables _fonts_main_ie_ big.css" />');
} else {
//Netscape
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_net_big.c ss" />');
}
break;
case 'small':
var navNam = navigator.appNa me;
var navVer= parseFloat(navi gator.appVersio n);
if (navNam.indexOf ('Microsoft') != -1 ) {
//IE
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_ie.css" />');
} else {
//Netscape
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_ie.css" />');
}
break;
}
}
function toggleFont()
{
var value;
value=readCooki e("size");
var name;
var c_value;
switch(value)
{
case 'big':
alert("i am inside big");
document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
setFont("small" );
break;
case 'small':
alert("i am inside small");
document.cookie ='size=big; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
setFont("big");
break;
default:
alert("cookie not found!");
document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
}
} [/CODE]
[HTML] //-->
</script>
<a class=pagenav href="#" onClick="javasc ript:toggleFont ();" >Text size</a></span>
[/HTML]
but the above code works in fire fox, but it is gives a blank page in ie,can any one help me with the issue?
i am trying to change the font of my web page with user preference.i made use of cookie to get the user's preference, so that the font size selected will remain for the next session. i am changing the style sheet with the cookie set, The below shown is my code
[CODE=javascript]function readCookie(name ) {
alert("i am Reading the cookies");
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(name EQ) == 0)
return c.substring(nam eEQ.length,c.le ngth);
}
}
return null;
}
function setFont(c_value )
{
switch(c_value)
{
case 'big':
var navNam = navigator.appNa me;
var navVer= parseFloat(navi gator.appVersio n);
if (navNam.indexOf ('Microsoft') != -1 ) {
//IE
document.write( '<link rel="stylesheet " type="text/css" href="/imagesvariables _fonts_main_ie_ big.css" />');
} else {
//Netscape
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_net_big.c ss" />');
}
break;
case 'small':
var navNam = navigator.appNa me;
var navVer= parseFloat(navi gator.appVersio n);
if (navNam.indexOf ('Microsoft') != -1 ) {
//IE
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_ie.css" />');
} else {
//Netscape
document.write( '<link rel="stylesheet " type="text/css" href="/images/variables_fonts _main_ie.css" />');
}
break;
}
}
function toggleFont()
{
var value;
value=readCooki e("size");
var name;
var c_value;
switch(value)
{
case 'big':
alert("i am inside big");
document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
setFont("small" );
break;
case 'small':
alert("i am inside small");
document.cookie ='size=big; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
setFont("big");
break;
default:
alert("cookie not found!");
document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
}
} [/CODE]
[HTML] //-->
</script>
<a class=pagenav href="#" onClick="javasc ript:toggleFont ();" >Text size</a></span>
[/HTML]
but the above code works in fire fox, but it is gives a blank page in ie,can any one help me with the issue?
Comment