Schriftgröße mit JavaScript ändern

Schriftgröße einer Seite mit JavaScript ändern.

Quelltext:  AusblendenKopierenLinkZeilen

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE HTML>
<
html>
 <
head>
  <
title>Schriftgröße ändern</title>

<
style>
body {
 
font-size12px;
 
font-familyVerdanaArialSans-Serif;
}
</
style>

<
script>
function 
setFontSize(size) {
 var 
body document.getElementsByTagName('body');
 for(var 
0< body.lengthi++) {
  if (
body[i].style.fontSize) {
   var 
parseInt(body[i].style.fontSize.replace("%",""));
  } 
  else {
   var 
size;
  }
  
body[i].style.fontSize size "%";
 }
}
</
script>

 </
head>
<
body>

<
p>
Schriftgröße ändern
<a style="font-size: 12px;" href="javascript:setFontSize('90');">A</a>
<
a style="font-size: 14px;" href="javascript:setFontSize('100');">A</a>
<
a style="font-size: 16px;" href="javascript:setFontSize('110');">A</a> 
</
p>

<
p> Lorem ipsum dolor ...</p>

</
body>
</
html>