Page 1 of 1

Basic Javascript Questions

Posted: Sat Jul 30, 2011 5:39 pm
by Mikari
I'm still new at JS though I have some knowledge of XHTML and CSS. I can do a few nice JS effects, but I want to go through my code and make it valid. I've started using JS Lint to validate code. I checked the Tolerate missing 'use strict' pragma box as I heard that it is not currently supported and shouldn't be used at the moment for internet content.

First question...

Problem at line 1 character 20: 'document' was used before it was defined.

The code works just fine, but I'm not sure what this is. It's a simple image swap for a linked picture to change on mouseover and back again on mouse out. This is referenced on a .inc file and used in the navigation of all the site's pages so the document would be any of those pages, right? Should I just ignore this error or is there a way to fix it. Pardon my being picky, it just doesn't seem enough to make things work when I want to properly learn this code.

function netdo() { document.netlink.src = "anet1.png"; }
function netup() { document.netlink.src = "anet2.png"; }

Re: Basic Javascript Questions

Posted: Sat Jul 30, 2011 5:57 pm
by Weirdan
You need to check 'Assume a browser' checkbox as well.

Re: Basic Javascript Questions

Posted: Sat Jul 30, 2011 9:25 pm
by Mikari
Thank you :) that solved the error as well as another similar error with an "undefined" window. I'll probably run into more questions as I try to learn more about JS so I'll be back the. Thanks for the fast reply!