View Single Post
  #30  
Old 08-12-2010, 09:30 PM
JavaScriptBank JavaScriptBank is offline
Senior Member
GB Guru
 
Join Date: Sep 2009
Posts: 180
Default Using JavaScript to Change Your Web Page Font Size

In this short JavaScript tutorial, <i>Nurani</i> 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 ... detail at JavaScriptBank.com - 2.000+ free JavaScript codes


How to setup

Step 1: Use JavaScript code below to setup the script
JavaScript
Code:
<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>
Step 2: Copy & Paste HTML code below in your BODY section
HTML
Code:
<a href="javascript:zoominLetter();">A</a>
<a href="javascript:zoomoutLetter();">a</a>





Reply With Quote