View Full Version : document.write seems to be ignored in netscape 4.6

Dec 5th, 2002, 01:08 AM
I am built a math quiz as an assignment for school. It works perfect in IE and in netscape 7, but in netscape 4.6 everything except the write at the end works. The code is

//see if answer is correct
if (document.quiz.ques_01.value ==
document.answers.answer_01.value) {
document.quiz.ques_01.value = document.quiz.ques_01.value + " correct";
document.quiz.ques_01.value = document.quiz.ques_01.value + " incorrect";
//write how many correct out of total questions
document.write(" You missed " + incorrectCount + " out of 7");

The complete code is attached
I am out of ideas on this one, any help is appreciated

thank you, garrett

Dec 5th, 2002, 01:15 AM
Who is using Netscape 4.6 ?!? :(

P.S. I don't see anything wrong with the code, offhand... of course I only test for NS 4.7 and above... but I don't think that would matter. :confused:

Try typing in "mocha:" or "javascript:" in Netscape in your address bar to see if you are getting any javascript errors.

Dec 5th, 2002, 02:04 AM
NS4 is picky when using document.write(). you need to use document.close()

document.write(" You missed " + incorrectCount + " out of 7");

Dec 5th, 2002, 02:05 AM
My teacher uses 4.6 to check my assignments. In ie or netscape 7 clicking the submit button replaces the document with "You missed x out of 7. When you hit the back button the answer fields have "correct" of "incorrect" in them. In netscape 4.6 the "correct" and "incorrect" are added to the fields, but the quiz is not replaced by the "you missed x out of 7". Thank you for taking the time to reply, garrett.

Dec 5th, 2002, 02:07 AM
heh... if I were you (I'm not recommending this, mind you), I would probably suggest to the teacher that he/she upgrade his/her browser, since it's pretty much obsolete (although knowing glenngv's expertise, his solution will likely work!). ;)

Anyone still using NS 4.6 (or any 4.x version) will no doubt experience errors whenever they surf the internet because it's just completely outdated (and has been for quite a while). :)

Perhaps if you're brave you'll give him/her a link to this thread, so he/she can explain his reasons for using such an outdated browser. At any rate, I'll take all of the blame, whether I'm right or wrong. ;)

Dec 5th, 2002, 02:12 AM
Thanx glenngv! that fixed my problem. What exactly does document.close() do? so I understand how it was fixed.
I think she checks it in 4.6 to be mean.... I havent read anything in my book about document.close() I never would have figured that out with out this forum.

Dec 5th, 2002, 02:15 AM
I guess I should amend my above posts to say him/her... ;)

Dec 5th, 2002, 02:27 AM
From DevGuru:

"In general, it is not necessary to open the document using the document.open method, since the document.write method will automatically open the file and discard (erase) the contents. However, after the write is complete, you need to close the document by using the document.close method. In some browsers, the results of the write may not be completely displayed, due to buffering, until the close occurs."

Dec 5th, 2002, 02:28 AM
Thanks again

Dec 5th, 2002, 02:31 AM
That's some news to me as well. ;)

I guess it's a good thing I don't use NS 4.x much... but I will store that information for future use (which I hope is not necessary!). :D

If I ever do start my own company, I know one guy who's going to be a paid consultant... lol

If you EVER need a technical reference regarding ASP or JavaScript (i.e. applying for a job), contact me Mr. Vergara. ;)

Dec 5th, 2002, 02:46 AM
Thank you very much whammy! ;)
If you don't mind, could you please PM me your personal info. :o
We don't know someday we would meet :D

Dec 5th, 2002, 02:50 AM
Done... if I can ever be of help to you, I owe you anyway. :D

Dec 5th, 2002, 02:55 AM
Thanks again my friend :)