熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

控制字體大小JS代碼

2022-06-13   來源: JSP教程 
  <script>
var tgs = new Array( divtdtr);
var szs = new Array( xxsmallxsmallsmallmediumlargexlargexxlarge );
var startSz = ;
function ts( trgtinc ) {
if (!documentgetElementById) return
var d = documentcEl = nullsz = startSzijcTags;
sz += inc;
if ( sz < ) sz = ;
if ( sz > ) sz = ;
startSz = sz;
if ( !( cEl = dgetElementById( trgt ) ) ) cEl = dgetElementsByTagName( trgt )[ ];
cElstylefontSize = szs[ sz ];
for ( i = ; i < tgslength ; i++ ) {
cTags = cElgetElementsByTagName( tgs[ i ] );
for ( j = ; j < cTagslength ; j++ ) cTags[ j ]stylefontSize = szs[ sz ];
}
}
</script>
<style>
tabfont{fontsize:px}
</style>
<body>
<a href="javascript:ts(body)">+ 放大字體</a> | <a
href="javascript:ts(body)">+ 減小字體</a><br><br>
<b>Javascript:</b><br><br>
<table align=center><tr><td class=tabfont>
var tgs = new Array( divtdtr);<br>
var szs = new Array( xxsmallxsmallsmallmediumlargexlargexxlarge );<br>
var startSz = ;<br>
function ts( trgtinc ) {<br>
if (!documentgetElementById) return<br>
var d = documentcEl = nullsz = startSzijcTags;<br>
sz += inc;<br>
if ( sz < ) sz = ;<br>
if ( sz > ) sz = ;<br>
startSz = sz;<br>
if ( !( cEl = dgetElementById( trgt ) ) ) cEl = dgetElementsByTagName( trgt )[ ];<br>
cElstylefontSize = szs[ sz ];<br>
for ( i = ; i < tgslength ; i++ ) {<br>
cTags = cElgetElementsByTagName( tgs[ i ] );<br>
for ( j = ; j < cTagslength ; j++ ) cTags[ j ]stylefontSize = szs[ sz ];<br>
}<br>
}<br>
</td></tr>
</table>
<p><a href="教程</a></p>
</body>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20145.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.