Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set font size in javascript change function

Status
Not open for further replies.

OMoore

Technical User
Oct 23, 2003
154
EU
Hi all

I have javascript that does the following: when the user puts the mouse on an image, text is shown in a specified location.

Problem is I cannot modify the size of the text. I need to set it to a certain size to prevent surfers from messing up the look of the page by increasing font size on their browsers. How do I set the font size manually and prevent this?

Code is as follows:

in the head section

<script language="JavaScript">
function change(html){
descriptions.innerHTML=html
}
</script>

In the body.....

<a href="mypage" onmouseover="javascript:change('my mouseover text')" onmouseout="javascript:change('my mouseout text')"><Img src="my image">

The output text appears from...

<div id="descriptions">All the text appears in here</div>

Thanks
Owen
 
Code:
<script language="JavaScript">
function change(html){
  descriptions.innerHTML=html
}
</script>


<a href="mypage" onmouseover="javascript:change('<font size=3>my mouseover</font>text')" onmouseout="javascript:change('<font size=6>my mouseout text</font>')"><Img src="my image">

<div id="descriptions">All the text appears in here</div>
 
Thanks Fendal.

The one problem with what you have above is that when I go to View..Text Size..Largest on my browser window all the text increases size.

I need the text to be unchaved - a funstion something lie.. style="font-size:15" .. but this won't go inside the javascript in the location you've placed the font tags above.
 
I need to set it to a certain size to prevent surfers from messing up the look of the page by increasing font size on their browsers

I don't think you can stop users doing that, I tested a few ways in FireFox and the text still increases.

even using

Code:
<style>
#descriptions {
font-size: 33px!important;
}
</style>

doesn't stop it.
 
I need to set it to a certain size to prevent surfers from messing up the look of the page
Has it occurred to you that they might be resizing the text in order to be able to read it, rather than to maliciously sabotage your layout?

Better to change your layout to cope with font resizing, than to attempt to make your site less usable in this way.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Fair point Chris.

I've already started to look at ways of doing this - making the sentences shorter/tables larger etc and then altering the text size to see how it looks.

Owen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top