Results 1 to 7 of 7

Thread: Document Text Sizer Script

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Document Text Sizer Script

    1) Script Title: Document Text Sizer

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

    3) Describe problem: my website pages contain ccs styles. This script resizes only the text without css style. How can apply on the script to change my styles as well?

    thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you use a relative unit (percentages are the only viable one, thanks to IE), the rest of your text will size with the base size.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your quick rensponse....i am quite new on the webdesign and as you can imagine allien to scripting. On the script customization says "First, within textsizer.js, you can add additional HTML tags the script should affect. Lets say your webpage's text are all controlled using explicit <font size="x"> tags. You can add "font" as a tag the script should affect.

    Second, inside the code of Step 2, you may substitute "body" with another tag name or even ID name, to localize the text size manipulation to only the specified containers."

    To be honest i dont understant what to type in order to change the "style 2" or "style 3" of my css styles.

    thanks

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    The script do overrides the CSS styles applied on the text (for me). You can try the below mentioned of mine to view that. It does present some illogical presentation while overriding the CSS styles.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    .body
    {
    color:#FF0000;
    font-size:18px;
    }
    </style>
    <script type="text/javascript">
    /*------------------------------------------------------------
    	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 ];
    		}
    	}
    }
    </script>
    </head>
    
    <body>
    <a href="javascript:ts('body',1)">+ Larger Font</a> | <a href="javascript:ts('body',-1)">+ Smaller Font</a>
    <br>
    <div class="body">This is a test</div>
    </body>
    </html>
    For example in my demo page I have a CSS class in which I've mentioned font-size: 18px so whenever the page loads the content on which the CSS class applied will be somewhat big, now If I press +Larger Font link then it will not increase the size of the present text on which I've applied instead it will try to incrase the font size to medium in this case medium is smaller than 18px so the result would be a decrease in the font-size which violates the very nature of this script.

  5. #5
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks it seems that it works (although some of the css styles they dont change but at least the main one does)

    x

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You still shouldn't be using absolute font sizes.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Document Text Sizer

    I am having trouble using this text sizer. I have tried every thing to no success.
    Any one have a suggestion?
    The page I am trying to resize the text is http://www.usa-cal.com/html/about_our_products.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •