This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes display text string with Javascript on screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "display text string with Javascript on screen" Watch "display text string with Javascript on screen" New topic
Author

display text string with Javascript on screen

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 245
How to display text string with Javascript on screen?

This is my test page:

I saw only "test docwrite(2);".
I want to see "test 1 hi hello docwrite(2);" with " 1 hi hello" coming from Javascript.
How to do that?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

Alberto,
First of all, that HTML is malformed. It is missing body tags. With malformed HTML, all bets are off as to what will happen.

If you were to add the body tags, you would run into a second problem. docwrite is called before it is defined. As a result, JavaScript doesn't know anything about a docwrite function. The JavaScript is ignored but doesn't run.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Consider Paul's rocket mass heater.
 
subject: display text string with Javascript on screen
 
Similar Threads
while-loop
Xml Dom not parsing
Help in iterating array from jsp
Validating Parser
Why to use eval function inside Javascript