This article describes the JS simple implementation of the font size of the page to adjust the method. Share to everyone for your reference, specific as follows:
var TGS = new Array (' div ', ' TD ', ' TR ');
var TGS = new Array (' TD ', ' TR ');
Specify spectrum of different font sizes:
//var Szs = new Array (' Xx-small ', ' x-small ', ' small ', ' medium ', ' large ', ' X-large ', ' xx-large ');
var Szs = new Array (' 10px ', ' 12px ', ' 14px ', ' 16px ', ' 18px ', ' 20px ', ' 22px ');
var Startsz = 2;
function Tsize (trgt,inc) {
if (!document.getelementbyid)
{
return
}
var d = document,cel = null, SZ = startsz,i,j,ctags;
SZ + Inc;
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]
;
}
}
How to use:
<TD width= ">
<a href=" javascript:tsize (' body ', 0) "> </a>
</td>
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary", "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and tips summary", " JavaScript error and debugging skills Summary, JavaScript data structure and algorithm skills summary, JavaScript traversal algorithm and skills summary and JavaScript mathematical calculation usage Summary
I hope this article will help you with JavaScript programming.