Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Thanked 0 Times in 0 Posts

    displaying specific day

    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];

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,573 Times in 2,551 Posts
    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
    Last edited by Philip M; 01-07-2012 at 07:33 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts