Webmaster

Tips
All Tips ]

Text that zooms in and out

A Java Script that will knock you out! Place this code between <HEAD> and </HEAD>:

<script language=javaScript>
<!--
// Vous pouvez modifier
var maxfontsize=40
var textcolor="AAAAAA"
var textfont="Arial"
var message="Your text"
// fin des modifications
var thissize=0
var step=1

function stretch() {
if (thissize<0) {step=1; thissize=0}
if (thissize < maxfontsize) {
if(document.all) {
zoomer.innerHTML="<span style='font-family:"+textfont+";font-size:"+thissize+"px;color:"+textcolor+"'>"+message+"</span>"
}

if(document.layers) {
document.zoomer.document.write("<span style='font-family:"+textfont+";font-size:"+thissize+"px;color:"+textcolor+"'>"+message+"</span>")
document.close()
}
step++
thissize=thissize+step
var timer=setTimeout("stretch()",50)
}
else {
clearTimeout(timer)
var intermezzo=setTimeout("shrink()",1000)
}
}

function shrink() {
if (thissize > -0) {
if(document.all) {
zoomer.innerHTML="<span style='font-family:"+textfont+";font-size:"+thissize+"px;color:"+textcolor+"'>"+message+"</span>"
}

if(document.layers) {
document.zoomer.document.write("<span style='font-family:"+textfont+";font-size:"+thissize+"px;color:"+textcolor+"'>"+message+"</span>")
document.close()
}
if (step >= 2) {step=step-1} else{step=1}

thissize=thissize-step
var timer=setTimeout("shrink()",50)
}
else {
clearTimeout(timer)
var intermezzo=setTimeout("stretch()",1000)
}
}
// -->
</script>

You can modify the maximum text size, text colour and text content.

In the <BODY> tag, add:

<Body onLoad="stretch()">

Then, after the tag <BODY>, add:

<div id="zoomer" style="position:absolute;visibility:visible;top:10px; left:10px"></div>

You can also modify the location where your animation is displayed by changing the parameters of top and left.

Discover all Webmaster tips.