Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    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">;
    </script>

    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
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 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
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 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.

    Code:
    <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">;
    }       
    
    </script>

    Quizmaster: Where is the sea Of Tranquillity?
    Contestant: Ibiza
    Last edited by Philip M; 01-07-2012 at 06: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
    •