<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 =
;
function ts( trgt
inc ) {
if (!document
getElementById) return
var d = document
cEl = null
sz = startSz
i
j
cTags;
sz += inc;
if ( sz <
) sz =
;
if ( sz >
) sz =
;
startSz = sz;
if ( !( cEl = d
getElementById( trgt ) ) ) cEl = d
getElementsByTagName( trgt )[
];
cEl
style
fontSize = szs[ sz ];
for ( i =
; i < tgs
length ; i++ ) {
cTags = cEl
getElementsByTagName( tgs[ i ] );
for ( j =
; j < cTags
length ; j++ ) cTags[ j ]
style
fontSize = szs[ sz ];
}
}
</script>
<style>
tabfont{font
size:
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(
div
td
tr
);<br>
var szs = new Array(
xx
small
x
small
small
medium
large
x
large
xx
large
);<br>
var startSz =
;<br>
function ts( trgt
inc ) {<br>
if (!document
getElementById) return<br>
var d = document
cEl = null
sz = startSz
i
j
cTags;<br>
sz += inc;<br>
if ( sz <
) sz =
;<br>
if ( sz >
) sz =
;<br>
startSz = sz;<br>
if ( !( cEl = d
getElementById( trgt ) ) ) cEl = d
getElementsByTagName( trgt )[
];<br>
cEl
style
fontSize = szs[ sz ];<br>
for ( i =
; i < tgs
length ; i++ ) {<br>
cTags = cEl
getElementsByTagName( tgs[ i ] );<br>
for ( j =
; j < cTags
length ; j++ ) cTags[ j ]
style
fontSize = 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