Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / JavaScript - Javascript in an html document (noob here!)

Author
Message
Neuro Fuzzy
18
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 2nd Sep 2009 07:42
I'm in a javascript class in my Highschool, so i figure i should start early. The first thing i usually do when figuring out a language is copy some code from some website and run it. I'm trying to get this game to work:
http://javascript.internet.com/games/ants.html

This is the code from that page:


I figure that using that code would look something like this:


But whenever i turn that into a .html file and open it, i just get an error that says "undefined".

I've put the ant images in "D:/" and replaced this line
var dir = "http://www.your-web-site-address-here.com/where-you-put-the-ant-images/";
with this:
var dir = "D:/";

But i still can't get the error to go away, and i have no clue what's causing this. Any help?
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Sep 2009 18:58
Where exactly is it saying undefined? Use the error console in FF, it's useful for this.

[url="http://www.nocleanfeed.com"][/url]
Neuro Fuzzy
18
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 5th Sep 2009 22:49
It's saying "Undefined" where the applet should be in the browser window.



No error in the error console :\

This is the exact code i was using (and i've triple checked that the images are in the D:\ directory).


I'm pretty sure it's not an error in the main code that i got from the internet, and that the problem is that i'm not putting the pieces together right :\
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 5th Sep 2009 23:03
Not that I know, but that "<!-- Begin" and "// End -->" parts doesn't look too well in there. Are you sure that you should write the words begin / end?

the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 6th Sep 2009 03:56
It's just really old javascript. It checks for netscape 4 which give a bit of an indication to how old it is.

It will probably work in internet explorer.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Neuro Fuzzy
18
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 6th Sep 2009 21:07
Ah, yeah, it works in IE, but it doesn't work with firefox, chrome, or opera. Does anyone know why that is?

I was worried i wasn't followin directions right :\
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Sep 2009 03:20
Ewwww, non-indented code. I see a lot of checks for IE and Netscape. I'm thinking if it doesn't detect one or the other then it does nothing. (probably because anything else back then would've been an unknown browser)

Login to post a reply

Server time is: 2026-06-10 02:56:41
Your offset time is: 2026-06-10 02:56:41