File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes document[].src returning null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "document[].src returning null" Watch "document[].src returning null" New topic

document[].src returning null

jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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?
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

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

Visit my download page
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
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
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
How about this?
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>"
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 ]
I agree. Here's the link:
subject: document[].src returning null
It's not a secret anymore!