Jump to content

Adjust Text Size


Dysan

Recommended Posts

Using JavaScript, is it possible to load different CSS files, upon different images being clicked?

 

Altogether, there will be 4 different text size settings, can the user can select, depending on how big the text needs to be, in order for the user to see correctly.

 

Upon each image being clicked, how do I load a different style sheet (CSS File)?

Link to comment
Share on other sites

If you google 'style switcher' you'll find all kinds of example scripts.  Find one you like and modify to suit.

 

If you don't want to use cookies, try php sessions. If you use neither, the text size switch will only last for the page being viewed.

 

A better alternative might be to use percentage size fonts and let the user control their choice of font size using the bulit-in browser options.

Link to comment
Share on other sites

If you google 'style switcher' you'll find all kinds of example scripts.  Find one you like and modify to suit.

 

If you don't want to use cookies, try php sessions. If you use neither, the text size switch will only last for the page being viewed.

 

A better alternative might be to use percentage size fonts and let the user control their choice of font size using the bulit-in browser options.

 

AndyB is right; the end user will have to keep reseting their preferred font size, if you do not use cookies/sessions. He is also right about using a percentage; instead of four completely different style sheet just to change the font size.

 

Do It Like This (No Cookies or Sessions Involved):

 

<script language="javascript">

function setFont(setSize)
{
document.getElementsByTagName('body')[0].style.fontSize = setSize;
}

</script>

</head>
<body>

<img src="small.jpg" onclick="setFont('75%')">
<img src="normal.jpg" onclick="setFont('100%')">
<img src="large.jpg" onclick="setFont('125%')">
<img src="xlarge.jpg" onclick="setFont('150%')">

<br><br>

Content Here

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.