Results 1 to 3 of 3

Thread: My getcurTime() function isn't working after initial load

  1. #1
    Join Date
    Jan 2008
    Location
    on earth
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My getcurTime() function isn't working after initial load

    this is my external jscript
    Code:
    // JavaScript Document
    function thisDoc(){
     
       document.write(" <b>The Title:</b> ",document.title, "<br>");
       document.write(" <b>The Location:</b> ", window.location, "<br>");
       document.write(" <b>The Date last modified:</b> ", document.lastModified, "<br>");
    
    }
    
    function theBrows(){
    
       document.write("<b>appCodeName:</b> ",
          navigator.appCodeName, "<br>")
       document.write("<b>appName:</b> ",
          navigator.appName, "<br>") 
       document.write("<b>appVersion:</b> ",
          navigator.appVersion, "<br>")
       document.write("<b>platform:</b> ",
          navigator.platform, "<br>")
       document.write("<b>userAgent:</b> ",
          navigator.userAgent, "<br>")
        
    }
    
    function yourDis(){
    
    	document.write( "<b>screen resolution:</b>", screen.width+'x'+screen.height, "<br>")
    	document.write( "<b>window dimensions:</b>", document.documentElement.clientWidth+'x'+document.documentElement.clientHeight, "<br>")
    
    }
    
    /*Add a last update statement at the bottom of Assignment5.htm, with the date supplied by the document's lastModified property. Display the date in the format of: Day Month Year at hour:minutes am/pm. Example: 25 October 2005 at 10:03 am. Create the function that formats the date in the external JavaScript file.*/
    
    function dateForm(){
    	var months = new Array("January", "February", "March", 
    						   "April", "May", "June", "July",
    						   "August", "September", "October",
    						   "November", "December")
    	
    	var today = new Date()
    	var hour = ""
    	var ext = ""
    	if (today.getHours() == 0) {
    		hour = 12
    		ext = "a.m."
    	} else if (today.getHours() < 12) {
    		hour = today.getHours()
    		ext = "a.m."
    	} else if (today.getHours() == 12) {
    		hour = 12
    		ext = "p.m."
    	} else {
    		hour = today.getHours() - 12
    		ext = "p.m."
    	}
    
    	
    	// *** INSTRUCTOR COMMENTS: This is today's date...not the date the document was last modified. ***
    	// Today is Day, Month, Year  
    	document.write("Last Modified: ",
    				   today.getDate(), ", ",
    				   months[today.getMonth()], " ",
    				   today.getFullYear()) 
    
    	// at Hours:Minutes
    	document.write("at ", hour, ":",
    				   today.getMinutes(), " ", ext)
    	
    }
    
    function getcurTime() { 
    				 window.setTimeout( "getcurTime()", 1000 );
    				 today = new Date();
    				 self.status = today.toString();
    			}
    and this is my html calling the function

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    
    
    <script language="JavaScript" src="myJS_2.js" type="text/javascript"></script>
    
    <title>Assignment 5</title>
    </head>
    <body>
    
    <body onLoad="thisDoc(), theBrows(), yourDis(), dateForm(), getcurTime() ">
    
    </body>
    </html>
    thanks in advance,
    david

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's broken.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    Transitional is outdated, and XHTML isn't supported by the most common browser yet. Stick to HTML 4.01 Strict for the time being.
    <script language="JavaScript" src="myJS_2.js" type="text/javascript"></script>
    The language attribute is deprecated.
    <body>

    <body onLoad="thisDoc(), theBrows(), yourDis(), dateForm(), getcurTime() ">
    You have two opening <body> tags; in Javascript, multiple statements are separated by semicolons, not commas.
    document.write(" <b>The Title:</b> ",document.title, "<br>");
    Don't use document.write() in this way. It will only work whilst the page is loading, for a start. Use DOM methods instead. <b> is presentational markup, and thus should be replaced by CSS. Read all the tutorials on http://www.howtocreate.co.uk/.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2008
    Location
    on earth
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default thanks

    Thanks for the help!!!

Bookmarks

Posting Permissions

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