实现方法:
前台:
<a href="javascript:ts('body',1)"><img src="images/dot_da2.gif" width="70" height="22" border="0"></a> <a href="javascript:ts('body',-1)"><img src="images/dot_xiao2.gif" width="69" height="22" border="0"></a>
var tgs = new Array( 'div'); //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 ]; } }
- 本文标题: 文章内容放大缩小功能,JS控制功能代码
- 文章分类:【HTML/CSS】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
- 上一篇:vs2005不能调试
- 下一篇: ASP.NET .cs后台为HTML标签UL动态添加li