»
EnglishFrenchVietnamese

Print - Using JavaScript to Change Your Web Page Font Size - JavaScriptBank.com

Full version: jsB@nk » Tutorials » How-to Tutorials » Using JavaScript to Change Your Web Page Font Size
URL: http://www.javascriptbank.com/using-javascript-change-web-page-font-size.html

Using JavaScript to Change Your Web Page Font Size © JavaScriptBank.comIn this short JavaScript tutorial, Nurani guides you how to use JavaScript in changing the web page's font size. Maybe the JavaScripts to change font size are not new things on jsB@nk, because we shared you a lot of JavaScript codes, tutorials for things such as increase font size, javascript font style, javascript text size, ... But this JavaScript tutorial is also good practice to study, let go to the full post-page for details.

Full version: jsB@nk » Tutorials » How-to Tutorials » Using JavaScript to Change Your Web Page Font Size
URL: http://www.javascriptbank.com/using-javascript-change-web-page-font-size.html



JavaScript
<script type="text/javascript">var min=8;var max=18;function zoominLetter() {   var p = document.getElementsByTagName('p');   for(i=0;i<p.length;i++) {      if(p[i].style.fontSize) {         var s = parseInt(p[i].style.fontSize.replace("px",""));      } else {         var s = 12;      }      if(s!=max) {         s += 1;      }      p[i].style.fontSize = s+"px"   }}function zoomoutLetter() {   var p = document.getElementsByTagName('p');   for(i=0;i<p.length;i++) {      if(p[i].style.fontSize) {         var s = parseInt(p[i].style.fontSize.replace("px",""));      } else {         var s = 12;      }      if(s!=min) {         s -= 1;      }      p[i].style.fontSize = s+"px"   }}</script>


HTML
<a href="javascript:zoominLetter();">A</a><a href="javascript:zoomoutLetter();">a</a>