<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>shake on mouseover</title>
<script type="text/javascript" language="javascript" charset="utf-8">
//
var ie=document.all?1:0;
var ns6=document.getElementById&&!document.all?1:0;
var ns4=document.layers?1:0;
var posleft=1; // change to numbers of pixels to chake (more is wider)
var idoftrembleobject="trembletext";
var trembleobject;
var timer = null;
function starttremble() {
if (ie || ns4 || ns6) {
if (ie) {
trembleobject=eval("document.all."+idoftrembleobject+".style")
}
if (ns6) {
trembleobject=idoftrembleobject
}
if (timer == null) {
timer = setInterval("dotremble();", 20);
}
}
}
function dotremble() {
posleft*=-1
if (ie) {
trembleobject.posLeft+=posleft
}
if (ns6) {
var newpos=parseInt(document.getElementById(trembleobject).style.left)+posleft
document.getElementById(trembleobject).style.left=newpos
}
}
function stoptremble() {
if (timer != null) {
clearInterval(timer);
timer = null;
}
}
//
</script>
</head>
<body bgcolor="#FFFFFF">
<div id="tremblebox" style="position:relative">
<span id="trembletext" style="position:absolute;left:10px;top:30px;" onmouseover="starttremble();" onmouseout="stoptremble();">
Look Here! This is your shaking text!
</span>
</div>
</body>
</html>
Jag ändrade startkoden lite och lade till stopkod.
Använd "onmouseover" och "onmouseout" som i koden över så ska det nog funka fint. Lycka till.