Javascript:
<SCRIPT LANGUAGE="JavaScript">
<!--
|
var dimages=new Array();
var numImages=2;
for (i=0; i<numImages; i++)
{
dimages[i]=new Image();
dimages[i].src="images/image"+(i+1)+".jpg";
}
var curImage=-1;
|
function swapPicture() { if (document.images) { var nextImage=curImage+1; if (nextImage>=numImages) nextImage=0; if (dimages[nextImage] && dimages[nextImage].complete) { var target=0; if (document.images.myImage) target=document.images.myImage; if (document.all && document.getElementById("myImage")) target=document.getElementById("myImage"); // make sure target is valid. It might not be valid // if the page has not finished loading if (target) { target.src=dimages[nextImage].src; curImage=nextImage; } |
setTimeout("swapPicture()", 5000);
|
}
else
{
setTimeout("swapPicture()", 500);
}
}
}
|
setTimeout("swapPicture()", 5000);
|
//-->
</SCRIPT>
|
Then here is the code to place it:
<IMG WIDTH=250 HEIGHT=250 ID="myImage" NAME="myImage"
SRC="images/image0.gif"></IMG>
]]>HTML5
CSS3
DOM
Canvas
WebGL
SVG
Native Client
WebSockets
Node.js
Javascript
I think this is awesome and I believe having an understanding of basic computer logic is a great skill to have. This is why I push software like Gamemaker, Squeak, Scratch, etc. which require one to understand basic programming logic.I also teach HTML, CSS, Javascript, PHP, and Actionscript in my classes.
However, I do think people are jumping the gun a bit with Javascript. The reason why? Javascript by itself is rather useless. I would not tell someone to learn javascript unless they had a solid foundation in HTML and CSS first. You really cant do anything with javascript without HTML. Learning javascript without HTML/CSS is like learning to hold your breath, then being put into a deep swimming pool without knowing how to swim.
So while I believe learning Javascript is great and I think everyone should learn basic programming…at least the logic, I believe that you should understand HTML and CSS before jumping the gun and learning Javascript.
So for those who want to learn js, just take a few weeks and learn HTML and CSS first. They are both very easy to learn – the easiest languages. Then when you have that foundation learn javascript. Then when you understand js, start learning a database language like PHP or Ruby.
]]>