Потому что нужно выбросить старые учебники и вкурить стандарты W3C 
| Код | <script type="text/javascript"> var msg =""; function chtxt(layID, html) { html +="<font size='5'>"; html += "Text2"; html += "</font>"; html += "<HR WIDTH=780>"; document.getElementById(layID).innerHTML=html; } </script>
<div id='sloi1'> <font size="5">text1</font> <hr width = 780> </div> <div> <a href="javascript:chtxt('sloi1',msg)">change text</a> </div> |
Можно чуть лучше:
| Код | <head><style type="text/css"> span.button { border: 2px solid #b1d7f3; margin: 3px; } a.button:link, a.button:visited { margin: 1px; padding: 2px 5px; background-color: #b1d7f3; font-family: Tahoma, Verdana; font-size: 13px; text-decoration: none; color: #0a3b50; font-weight: bold; } a.button:hover {background-color: #d3f581;} a.button:active {background-color: #62d701;} </style>
<script type="text/javascript"> function chtxt2(layID, msg) { document.getElementById(layID).innerHTML=msg; } </script> </head>
<body>
<div> <span id="sloi2" style="font-family: Arial; font-size: 16pt;">Text1</span> <hr width = 780> </div> <div> <span class="button"><a class="button" href="javascript: void(0);" onclick="chtxt2('sloi2','Text 2')">change text</a></span> </div> | |