|
|
bigger text
Applying a textual formatting application is very easy in the most current versions of the DHTML specifications. Simply use any CSS rule that has been included in the DOM specifications. In this case, we’re altering the sizing of text. We’ll take it a step further and introduce a timer and a maximum text size. Examine the below construction:
<html>
<head>
<script type="text/javascript">
txtsize=0;
maxsize=100;
function writemsg() {
if (txtsize<maxsize) {
document.getElementById('msg').style.fontSize=txtsize;
txtsize++;
timer=setTimeout("writemsg()",10);
}
}
function stoptimer() {
clearTimeout(timer);
}
</script>
</head>
<body onload="writemsg()" onunload="stoptimer()">
<p id="msg">W3Schools!</p>
</body>
</html>
The style.fontSize attribute is used to change the size of the text. There are many style rules that can be used in this exact same location in this exact way to change many different textual formatting options. However, you are not limited to applying only one textual formatting option per function - may also apply groups of rules to construct the look and feel you’re thinking of.
The timer was introduced to provide for older browsers that take a little bit of time to apply a text change and redraw the document. The value given is 10 and is stated in milliseconds. This gives the legacy browser time to make the change and be ready to redraw. Otherwise the browser will throw an error when it tries to apply the formatting change.
|
|