Js allows you to adjust the font size of a webpage. js allows you to adjust the font size of a webpage.

Source: Internet
Author: User

Js allows you to adjust the font size of a webpage. js allows you to adjust the font size of a webpage.

This document describes how to adjust the font size of a web page in JavaScript. We will share this with you for your reference. The details are 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 ];    }  }}

Usage:

<td width="13"><a href="javascript:tsize('body',0)"></a></td>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.