View Full Version : displaying specific day

01-07-2012, 01:35 PM
I am having a problem with my homework displaying an iframe using JavaScript.
My homework states:

Insert a script element that does the following:

part a. Insert the following multiline comment:
Display the daily schedule in an inline frame. Daily schedules are stored in the files
sunday.html through saturday.htm.

part b.
Insert a command to write the HTML code
<iframe src="weekday.htm'></iframe>

to the Web page, where weekday is the text string returned by the weekDay() function.

What I have so far:
<script type= "text/javascript">
/* Display part a */

document.write("<iframe src='weekday.htm'></iframe">;

My Question:
How do I display weekday.htm within my script on a specific day using the function weekDay() function.

below is my weekDay() function:
function weekDay(){
thisDate = new Date();
var thisWDay=thisDate.getDay();
var wdName = new Array("sunday", "monday", "tuesday", "wednesday",
"thursday", "friday", "saturday");
return wdName[thisWDay];

01-07-2012, 07:07 PM
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript forum.

Philip M
01-07-2012, 07:30 PM
Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia!

There is no file weekday.htm. You are expected to load a file whose name corresponds to the name of the day of the week. Don't forget the multi-line comment.

<body onload = "weekDay()">

<script type = "text/javascript">

function weekDay(){
thisDate = new Date();
var thisWDay = thisDate.getDay();
var wdName = new Array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
var URL = wdName[thisWDay] + ".htm";
document.write("<iframe src= URL></iframe">;


Quizmaster: Where is the sea Of Tranquillity?
Contestant: Ibiza

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum