动态改变网页文字大小的脚本[JS]

第一步:在区加上如下代码:
引用内容 引用内容


第二步:在网页内容中添加二个链接:
引用内容 引用内容


textsizer.js 的代码如下:
引用内容 引用内容
/*------------------------------------------------------------
    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 ];
    }
}
[本日志由 parno 于 2012-04-18 02:15 AM 更新]
上一篇: 39款兔斯基 QQ 表情下载[RAR][EIP]
下一篇: 解码 Winmail.dat 邮件附件的工具下载[RAR]
文章来自: dynamicdrive.com
引用通告: 查看所有引用 | 我要引用此文章
Tags: javascri&#112;t DHTML CSS
相关日志:
评论: 0 | 引用: 0 | 查看次数: 7694
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 500 字 | UBB代码 关闭 | [img]标签 关闭