日期:2014-05-16 浏览次数:20424 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <htmL> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <style> #content {font-size:12px; line-height:200%; padding:10px; } </style> <script language="javascript"> function setfont(size) { var obj; obj=document.getElementById("content"); obj.style.fontSize=size; //obj.style.color="#ff0000"; } </script> <body> <div>字体: <a href="#" onclick="javascript:setfont('12px')">小</a><a href="#" onclick="javascript:setfont ('18px');">中</a><a href="#" onclick="javascript:setfont('24px');">大</a></div> <div id="content"> hello world </div> </body> </htmL>
<script> var tgs = new Array( 'div','td','tr'); 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> <style> .tabfont{font-size:12px} </style> <body> <a href="javascript:ts('body',1)">+ 放大字体</a> | <a href="javascript:ts('body',-1)">+ 减小字体</a> hello world </body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <htmL> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <style> #content {font-size:12px; line-height:200%; padding:10px; } </style> <script language="javascript"> //更改字体大小 var status0=''; var curfontsize=10; var curlineheight=18; function turnsmall(){ if(curfontsize>10){ document.getElementById('art_content').style.fontSize=(--curfontsize)+'pt'; document.getElementById('art_content').style.lineHeight=(--curlineheight)+'pt'; } } function turnbig(){ if(curfontsize<28){ document.getElementById('art_content').style.fontSize=(++curfontsize)+'pt'; document.getElementById('art_content').style.lineHeight=(++curlineheight)+'pt'; } } </script> <body> 字体:[<a href="javascript:turnbig()">增加</a> <a href="javascript:turnsmall()">减小</a>] <div id="art_content"> 文本 </div> </body> </htmL>