Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

document[].src returning null

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following JavaScript:

The default image comes up fine, however when I move the mouse to the image, I get an error stating that document[...] is null or not an object. I've been following a tutorial, and this example is pretty much identical. Is there something wrong with the JavaScript code, or is it something with my system?
Thanks!
Jason
 
Randall Twede
Ranch Hand
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cant spot the error but im not an expert on js. one possibility is that you accidently have said picl instead of pic1, or vice versa
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the problem, and it's of course the simple solution.

I was refreshing one browser session while I had another one open, also. Wasn't actually refreshing. Once I closed both browsers and re-opened, worked fine

Now my problem is trying to figure a way to get a running clock working without actually sticking the clock into an input form. Wish HTML had a label type thing that you could repeatedly update, but that's a topic for another post
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this?
<HTML>
<HEAD><TITLE>Test Page</TITLE></HEAD>
<BODY>
<DIV ID="CLOCK">
</DIV>
<SCRIPT LANGUAGE="JAVASCRIPT">
setInterval("showDate()",1000)
function showDate()
{
var myDate = new Date()
var hours = myDate.getHours()
var minutes = myDate.getMinutes()
var seconds = myDate.getSeconds()
if(hours < 10)
{
hours = '0' + hours
}
if(minutes < 10)
{
minutes = '0' + minutes
}
if(seconds < 10)
{
seconds = '0' + seconds
}
CLOCK.innerHTML = "<h1>" + hours + ":" + minutes
+ ":" + seconds+ "</h1>"
}
</SCRIPT>
</BODY>
</HTML>
It will work in IE, anyway. You would have to cross-browserize the code to make it work in Netscape.
[ April 11, 2002: Message edited by: Bodie Minster ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic