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
JavaScript

Avatar of undefined
Last Comment
dynamicOne

8/22/2022 - Mon
SOLUTION
Robert Schutt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dynamicOne

ASKER
Thanks for catching that. Now it opens and closes right away.
ch9.html
document-open.js
Robert Schutt

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.
dynamicOne

ASKER
Okay, thanks for point that out. I want the message to stay, but it disappears right away.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Robert Schutt

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?
dynamicOne

ASKER
It happens in Chrome and Safari. The text disappears too fast to do a screenshot.
Robert Schutt

And View Source?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Robert Schutt

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.
Robert Schutt

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
Robert Schutt

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dynamicOne

ASKER
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Robert Schutt

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.
dynamicOne

ASKER
Ok, thanks!