[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Error: 'document.Clock.document' is null or not an object

Posted on 2004-04-29
12
Medium Priority
?
740 Views
Last Modified: 2013-12-03
I am getting this error (Error: 'document.Clock.document' is null or not an object) when executing the following code:

<%      'Detecting browsers used by the users
      set Brow=Server.CreateObject("MSWC.BrowserType")
      BrowType=Brow.Browser
%>

<html>
<head>
<title>Header Page</title>
<META HTTP-EQUIV = "Pragma" CONTENT="no-cache">

<SCRIPT LANGUAGE="JavaScript">
<!--
var timerID = null
var timerRunning = false
var TimeDiff = null

function stopclock(){
      if(timerRunning)
            clearTimeout(timerID)
      timerRunning = false
}

function startclock(){
      // computing time difference between the server and the client machine
      var now = new Date()
      var ClientT = Date.UTC(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds())
      TimeDiff=arguments[0]*1000-ClientT
      
      // Make sure the clock is stopped
      stopclock()
      showtime()
}

function showtime(){
   var dayList = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
   var monthList = new Array("Jan","Feb","Mar","Apr","May","Jun","July","Aug","Sep","Oct","Nov","Dec")
   var adjust = null
   
   var now = new Date()
   var ClientT = Date.UTC(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds())
   ClientT = ClientT+now.getTimezoneOffset()*60000+TimeDiff
   
   var now = new Date(ClientT)
   var seconds = now.getSeconds()
   var minutes = now.getMinutes()
   var hours = now.getHours()
   var date = now.getDate()
   var day = now.getDay()
   var month = now.getMonth()
   
   var timeValue = "" + dayList[day] + ", "
   timeValue += monthList[month] + " "
   timeValue += date + ", "
   timeValue += ((hours > 12) ? hours - 12 : hours)
   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
   timeValue += ((seconds < 10) ? ":0" : ":") + seconds
   timeValue += (hours >= 12) ? " PM " : " AM "
   <%if BrowType="IE" then%>
   Clock.innerHTML = timeValue;
   <%else%>
   document.Clock.document.write("<FONT face='Verdana,Arial' color=crimson size=1><B><U>"+timeValue+"</U></B></FONT>")
   document.Clock.document.close()
   <%end if%>      
   timerID = setTimeout("showtime()",1000)
   timerRunning = true
}
-->
</SCRIPT>
</head>

<%      date1=cdate("1/1/1970")
      date2=now
      TimeDiff=datediff("s",date1,date2)
%>

<BODY onLoad="startclock(<%=TimeDiff%>)">

<TABLE Height=85 width=500>
<TR>
      <TD align=middle><FONT color=mediumblue face=Arial size=5 >
            <STRONG>IE-597D Response Surface Methodology</STRONG></FONT>
    </TD></TR>
<TR>
    <TD align=middle><FONT color=mediumblue face=Arial size=4 >Process Simulator</FONT>
    </TD></TR>  
<TR>
      <TD align=right>
      <%if BrowType="IE" then%>
            <FONT face="Verdana,Arial" color=crimson size=1><B><U>
            <DIV id=Clock>&nbsp;</DIV></U></B></FONT>
      <%else%>
            <LAYER ID="Clock" left="350" top="80">&nbsp;</LAYER>
      <%end if%>      
      </TD>
</TR>
</TABLE>
</body>
</html>

NOTE:  I took this code from an IIS3 server and am trying to run it on an IIS5 server.  I don't know much about ASP or javascripting.

Any suggestions?  
0
Comment
Question by:SherryG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 10953679
Print out the value for BrowType.
Perhaps is the string NOt "IE" event when it is talking to IE, perhaps it is lowercase, or some additional information.

<%if BrowType="IE" then%>

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10953696
Oh, and to see the value in browser print it like this:

<BODY onLoad="startclock(<%=TimeDiff%>)">
BrowType: <b><%=BrowType%></b><br>




0
 

Author Comment

by:SherryG
ID: 10953738
Very strange.  When I added that line and ran the page I got brow type = Netscape, but I was using IE 6.  When I ran the page on a different machine with netscape I got brow type = default.

Any thoughts?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 63

Accepted Solution

by:
Zvonko earned 800 total points
ID: 10953939
Check this:

<html>
<head>
<title>Header Page</title>
<META HTTP-EQUIV = "Pragma" CONTENT="no-cache">

<SCRIPT LANGUAGE="JavaScript">
<!--
var timerID = null
var timerRunning = false
var TimeDiff = null

function stopclock(){
     if(timerRunning)
          clearTimeout(timerID)
     timerRunning = false
}

function startclock(){
     // computing time difference between the server and the client machine
     var now = new Date()
     var ClientT = Date.UTC(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds())
     TimeDiff=arguments[0]*1000-ClientT
     
     // Make sure the clock is stopped
     stopclock()
     showtime()
}

function showtime(){
   var dayList = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
   var monthList = new Array("Jan","Feb","Mar","Apr","May","Jun","July","Aug","Sep","Oct","Nov","Dec")
   var adjust = null
   
   var now = new Date()
   var ClientT = Date.UTC(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds())
   ClientT = ClientT+now.getTimezoneOffset()*60000+TimeDiff
   
   var now = new Date(ClientT)
   var seconds = now.getSeconds()
   var minutes = now.getMinutes()
   var hours = now.getHours()
   var date = now.getDate()
   var day = now.getDay()
   var month = now.getMonth()
   
   var timeValue = "" + dayList[day] + ", "
   timeValue += monthList[month] + " "
   timeValue += date + ", "
   timeValue += ((hours > 12) ? hours - 12 : hours)
   timeValue += ((minutes < 10) ? ":0" : ":") + minutes
   timeValue += ((seconds < 10) ? ":0" : ":") + seconds
   timeValue += (hours >= 12) ? " PM " : " AM "
   if(document.getElementById){
     document.getElementById("Clock").innerHTML = timeValue;
   } else if(document.all){
     Clock.innerHTML = timeValue;
   }else{
     document.nClock.document.write("<FONT face='Verdana,Arial' color=crimson size=1><B><U>"+timeValue+"</U></B></FONT>")
     document.nClock.document.close()
   }
   timerID = setTimeout("showtime()",1000)
   timerRunning = true
}
-->
</SCRIPT>
</head>


<BODY onLoad="startclock(0)">

<TABLE Height=85 width=500>
<TR>
     <TD align=middle><FONT color=mediumblue face=Arial size=5 >
          <STRONG>IE-597D Response Surface Methodology</STRONG></FONT>
    </TD></TR>
<TR>
    <TD align=middle><FONT color=mediumblue face=Arial size=4 >Process Simulator</FONT>
    </TD></TR>  
<TR>
     <TD align=right>
          <FONT face="Verdana,Arial" color=crimson size=1><B><U>
          <DIV id=Clock>&nbsp;</DIV></U></B></FONT>
          <LAYER ID="nClock" left="350" top="80">&nbsp;</LAYER>
         
     </TD>
</TR>
</TABLE>
</body>
</html>

0
 

Author Comment

by:SherryG
ID: 10958730
That seems to work great.  Thanks.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10958775
You are welcome.
0
 

Author Comment

by:SherryG
ID: 10962357
Woops.  I just noticed that everytime I go to the page the date and time it displays and starts counting from is Wed, Dec 31, 11:00:00 PM.

Any idea why it might do that?  I checked and the time is correct on the server.
 
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10963062
Do you pass the correct offset in the body tag:
<BODY onLoad="startclock(<%=TimeDiff%>)">

The offset has to be in miliseconds.
Check the value again with the print.
Like this:
<BODY onLoad="startclock(<%=TimeDiff%>)">
TimeDiff: <b><%=TimeDiff%></b><br>


0
 

Author Comment

by:SherryG
ID: 10963168
When I pasted those two lines to my page nothing displays after TimeDiff:  and I get (undefined, undefined NaN, NaN:NaN:NaN AM) where the date used to appear.

 
0
 

Author Comment

by:SherryG
ID: 10963283
I think I got it.  I added the

<%     date1=cdate("1/1/1970")
     date2=now
     TimeDiff=datediff("s",date1,date2)
%>

back in just before my body tag and it seems to be working.

Sorry for being such a putz at this.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10963324
Put this lines before the <body> tag:
<%    
     date1=cdate("1/1/1970")
     date2=now
     TimeDiff=datediff("s",date1,date2)
%>


0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10963331
Ok, you managed it :)
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question