PDA

View Full Version : Dynamic Text Sizer won't work in IE6 or IE7



vegeman
11-19-2008, 04:32 PM
1) Script Title:
Dynamic Text Sizer

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex9/textsizer.htm

3) Describe problem:
The script works fine in NS, FF and Safari but will not work in IE6 or IE7. Does anyone have a fix? I should note that the DD page works fine in IE6&7, not mine: http://www.goldenyearscomputer.com/about2.htm Thanks.

Head script:

<script type="text/javascript" src="textsizer.js">

/***********************************************
* Document Text Sizer- Copyright 2003 - Taewook Kang. All rights reserved.
* Coded by: Taewook Kang (http://www.txkang.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

Body script:

<a href="javascript:ts('body',1)">+ Larger Font</a> | <a
href="javascript:ts('body',-1)">+ Smaller Font</a>

External .js file:

/*------------------------------------------------------------
Document Text Sizer- Copyright 2003 - Taewook Kang. All rights reserved.
Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
Web Site: http://txkang.com
Script featured on Dynamic Drive (http://www.dynamicdrive.com)

Please retain this copyright notice in the script.
License is granted to user to reuse this code on
their own website if, and only if,
this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr');

//Specify spectrum of different font sizes:
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
var startSz = 2;

function ts( trgt,inc ) {
if (!document.getElementById) return
var d = document,cEl = null,sz = startSz,i,j,cTags;

sz += inc;
if ( sz < 0 ) sz = 0;
if ( sz > 6 ) sz = 6;
startSz = sz;

if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

cEl.style.fontSize = szs[ sz ];

for ( i = 0 ; i < tgs.length ; i++ ) {
cTags = cEl.getElementsByTagName( tgs[ i ] );
for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
}
}