Only works in Firefox

M

Michael

Firstly I'm not a Javascript pro but I know enough to get things
working in Firefox, I program in other languages so you don't need to
dumb down what you say though.

I've made this hangman script and it works fine in Mozilla Firefox but
not in IE6 or Opera 9. Could someone fix this for me please or tell me
where I'm going wrong. I think the problem has something to do with
global variables but I'm not sure.

Working (in firefox) version:
http://michael-m.co.uk/langlearnbeta/hangman/

Javascript Source:
http://michael-m.co.uk/pastebin/?show=4

HTML Source:
http://michael-m.co.uk/pastebin/?show=5

Thanks in Advance,
Michael Mulqueen
 
M

Martin Honnen

Michael wrote:

I've made this hangman script and it works fine in Mozilla Firefox but
not in IE6 or Opera 9.

One problem I see is your attempt to iterate over the charactes in a
string with for..in and indexing characters in the string with square
brackets.
Use e.g.
for (var i = 0, l = string.length; i < l; i++) {
// access string.charAt(i) for character at index i
}
instead, that is what should work with any JavaScript implementation
nowadays.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top