more javascript
1. Ahmed's funky script :
2. What have you been doing?
- look at homework / your javascript tutorial work.
3. This week: continue to explore javascript and programming.
4. Forms in HTML : go over the basics.
5. Some new syntax and programming ideas :
conditionals and booleans
// javascript code
your_name = prompt("What is your name?")
if (your_name == "Jim"){
alert("Hi Jim!");
}
else {
alert("Your name isn't 'Jim'.);
}
loops and "accumulating"
i = 0;
result = "";
while (i < 10){
i = i + 1;
result = result + "<li>" + i + </li>\n";
}
theLoopOutput = document.getElementById("loopOutput");
theLoopOutput.innerHTML = "<ul>\n" + result + "</ul>\n";
example 1 : daytime/nighttime background image.
Time in javascript? Google "javascript time".
currentTime = new Date(); // an object that has the current time.
if (currentTime.getHours() < 6 || currentTime.getHours > 19){
imageURL =
"http://www.marlboro.edu/graphics/front_page_banners/art_class";
}
else {
imageURL = "...";
}
head = document.getElementById("header");
head.style.backgroundImage = "url(" + imageURL + ")";
example 2 : slideshow
Google "javascript wait".
Then have an image that changes every 10 seconds or so.
example 3 : moving something around on the page
In a loop, change position css property of something.
example 4 : changing style sheets
javascript libraries