Link to home
Start Free TrialLog in
Avatar of dynamicOne
dynamicOne

asked on

Javascript Error

This may be a simple one, but I keep getting an error when clicking the button after some text is entered.

You'll have to click the button repeatedly to see the error. The error is on line 2.
lp3-ch9-DOM-ML.html
lp3-ch9-DOM-ML.js
SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dynamicOne
dynamicOne

ASKER

Thanks for catching that. Now it opens and closes right away.
ch9.html
document-open.js
Not sure what you mean. The function overwrites the current document (in Internet Explorer) so the input form is gone after submitting it. If that's not what you need, you may need another way to implement this than via document.open/write/close (do you need a popup perhaps?)

Note that in your original code there's a reference to a class you seem to be taking (?), I didn't see the harm in pointing out a typo but if you need more help with an assignment, EE has pretty strict rules about that. Pointers only, no complete solutions.
Okay, thanks for point that out. I want the message to stay, but it disappears right away.
What browser do you use? Can you post a screenshot of how it looks afterwards and/or use View Source in the browser to look at what happened?
It happens in Chrome and Safari. The text disappears too fast to do a screenshot.
And View Source?
Ah, I am able to reproduce in Safari. So what is your intention? Show the output, then just sit there? That is what happens in IE.
Maybe what you could do is put the output in a popup window or a div element (just some examples) instead of using document.write?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I just want to produce the text and let it sit there. If it works in IE then that's good. I'm on a Mac so I can't test it in IE.
I guess in Safari (and Chrome) the form is submitted and that's why the page is displayed 'fresh' again. The "return false" prevents that.
Ok, thanks!