Link to home
Start Free TrialLog in
Avatar of techiebabe
techiebabe

asked on

Changing the font size

I'd like to be able to let the user increase or decrease the font size of a site as they navigate through the site.  I need to implement this on both classic asp and .net.

Here's  a link to what I'd like to do - http://www.pfizerforliving.com.

If you look over to the right side of the page, the text reads:

Text Size:        A        A        A        A

Each time you click on the A, the font size will either increase or decrease.  Can someone send me some information as to how I can implement this on my site.  I use a stylesheet to change the text on my pages.

Thanks!
Avatar of mcv22
mcv22
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of stu_pb
stu_pb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of techiebabe
techiebabe

ASKER

stu_pb

I wasn't sure if I had create two style sheets.  I was hoping to avoid that, but again, I wasn't sure.  Thanks.  
You could also try with javascript.  This way you will not need to include font sized in your CSS and you can have only one.  It may be really slow though, I have never tried anything like this.

function ChangeFont(size)
{
     for (var i = 0;i < document.all.length;i++)
     {
          document.all[i].style.fontSize = size;
     }
}

You might have to filter out certain types of elements if they don't implement the fontSize property, but most of them should I think.

Good Luck!
You could use something like this then (so that you need not use 2 stylesheets):

<%
If Session("FontSize") = 5 Then
     Response.Write "<style type='css/text'>body{ font-size:5px; }"
Else
     Response.Write "<style type='css/text'>body{ font-size:6px; }"
End If
%>

Any CSS code within the HTML document will 'override' the CSS Stylesheet. :)

Regards;
Oops, add an end of script tag: </script>  to each response.
dammit. lol. sorry, that should be end of style tag (</style>), so use this:

<%
If Session("FontSize") = 5 Then
     Response.Write "<style type='css/text'>body{ font-size:5px; }</style>"
Else
     Response.Write "<style type='css/text'>body{ font-size:6px; }</style>""
End If
%>

lol - sorry
InteractiveMind - thanks I think that would definitely work, however, there are differnet font-sizes on the page, it may not work for all.

 stu_pb - i think you're right about the js.  

Give me a few days to test it out and I will accept the answer I go w/ in a few days.  Thanks for your efforts!!!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial