Salve a tutti!!!
Ho copiato questo script da un libro molto noto, sono ovviamente alle prime armi con js ma non ad esempio con as di flash, ma anche qui non sono un cosidetto veterano. Volevo comuqnue rendermi conto dell'effetto fly-in.
Quindi ho copiato questo script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fly-in</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
div {padding: 10px;}
#div {background-color: #00f;
color: #fff;
font-size: larger;
position: absolute;
width: 400px;
height: 200px;
left: -410px;
top: -400px;
}
#div {background-color: #ff0;
color: #;
font-size: larger;
position: absolute;
width: 400px;
height: 200px;
left: -410px;
top: -400px;
}
#div {background-color: #f00;
color: #fff;
font-size: larger;
position: absolute;
width: 400px;
height: 200px;
left: -410px;
top: -400px;
}
</style>
<script type="text/javascript">
//<![CDATA[
var element = ["div1","div2","div3"];
function next(){
setTimeout("moveBlock()", 1000);
}
var x = 0;
var y = 0;
var elem = 0;
function moveBlock(){
x+=20;
y+=20;
var obj = document.getElementById(element[elem]);
obj.style.top = x + "px";
obj.style.left = y = "px";
if (x< (100 + elem * 60)) {
setTimeout("moveBlock()", 100);
}else{
elem++;
x = 0; y = 0;
}
}
//]]>
</script>
</head>
<body>
Next Slide
</p>
< div id="div1">
Now is the time for all good wo-men to come eo the aid of their country.
</div>
< div id="div2">
99 bottles of beer on the wall, 99 bottles of beer...
Take one down, pass it around, 98 bottles of beer one...
</div>
< div id="div3">
web 2.0 WEB 2.0 WeB 2222....0000
I'm so cool,</p>
<h2>Learning JavaScript!</h2>
</div>
</body>
</html>
Ho salvato il file prima come .js ma non mi dava il fly-in ma solo del testo e ora come index.html la pagina del mio sito mi da questo:
Next Slide
< div id="div1"> Now is the time for all good wo-men to come eo the aid of their country. < div id="div2"> 99 bottles of beer on the wall, 99 bottles of beer...
Take one down, pass it around, 98 bottles of beer one...
Non capisco dove sia l'errore...
Qualcuno saprebbe indicarmi cosa c'è che non va?
Ciao e grazie !!!![]()