Presentation is loading. Please wait.

Presentation is loading. Please wait.

Making Pages Dynamic Chapter 8 JavaScript for the WWW.

Similar presentations


Presentation on theme: "Making Pages Dynamic Chapter 8 JavaScript for the WWW."— Presentation transcript:

1 Making Pages Dynamic Chapter 8 JavaScript for the WWW

2 Outline Detect if Java or JavaScript is enabled Put current date into Webpage Detecting the referrer page There’s lots more in Chapter 8, including a table of 42 date methods

3 Do you have Java? document.write("Java is ") if (!navigator.javaEnabled()) { document.write("not ") } document.write("enabled.") JavaScript is not enabled. http://itri2.org/s/CS456/script02.13.html

4 Detection of the current date Date methods reads client PC clock and converts to various formats This script simply outputs the current date, but to do so it has to have available the names of the days of the week, and months of the year in arrays There are several other date scripts in the chapter

5 Dynamic Date Display dayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Sat urday") monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") now = new Date document.write(" Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " " + now.getDate() + ". ") http://itri2.org/s/CS456/script08.01

6 Working with Referrer Page This is very easy if you can spell “referrer” However, you do need to have a link on the referrer page to this script’s page. Testing by entering the script’s URL into the File > Open or browser location box does not seem to work document.write (document.referrer) prints the URL of the previous Webpage onto this one.

7 Do you like me? if (document.referrer != "") { document.write(" I hope you like this page better than " + document.referrer + ". ") } http://itri2.org/s/CS456/Referrer.html


Download ppt "Making Pages Dynamic Chapter 8 JavaScript for the WWW."

Similar presentations


Ads by Google