document.write()

P

PaPa

I notice that document.write() normally writes text (or variables) to
the "immediate" page (window??) on the screen. At other times, it
erases the "immediate" page and writes to a new page.

In my ramblings, this seems to happen randomly, but I'm sure it cannot
be a random thing.

I read something about using document.write() within an onClick
statement. It seemed to confirm this "new window" behavior.

It doesn't make sense to me that this behavior should occur. Can
someone explain why this happens?

Also, is there a rule or construct which I can hang my hat on when it
comes to exactly where document.write() is going to write?

(P.S. Guys, take it easy on me. I'm just an old man trying to learn.)
 
M

Martin Honnen

PaPa said:
Also, is there a rule or construct which I can hang my hat on when it
comes to exactly where document.write() is going to write?

document.write during loading of the current document writes to that
document. If you do document.write after the document has been loaded an
implicit document.open() is done first which means the document is
overwritten.
 
J

Jeremy J Starcher

Also, is there a rule or construct which I can hang my hat on when it
comes to exactly where document.write() is going to write?

While document.write is not officially obsolete, many people discourage
its use.

Rather than try to learn the ins and outs of document.write, I would
*strongly* suggest that learn proper DOM usage as well.

The DOM (or Document Object Model) can be used to change, delete or add
any element on the screen.

<URL: http://www.w3.org/DOM/ )

Its a bit of heavy reading, but worth it.
 
T

Thomas 'PointedEars' Lahn

Jeremy said:
While document.write is not officially obsolete, many people discourage
its use.

Those people would not know what they are talking about:

http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75233634
Rather than try to learn the ins and outs of document.write, I would
*strongly* suggest that learn proper DOM usage as well.

document.write() is "proper DOM usage".
The DOM (or Document Object Model) can be used to change, delete or add
any element on the screen.

And even off-screen.
<URL: http://www.w3.org/DOM/ )

Its a bit of heavy reading, but worth it.

Yes, indeed. Please do.


PointedEars
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
cor-online.net>, Fri, 4 Jan 2008 14:09:00, Martin Honnen

document.write during loading of the current document writes to that
document. If you do document.write after the document has been loaded
an implicit document.open() is done first which means the document is
overwritten.

</FAQENTRY>
 
H

Henry

On Jan 7, 12:56 pm, Richard Maher wrote:
Cross browser Applet invocation cannot be ignored in these
discussions surely?
<snip>

Weren't Applets generally abandoned in public web site use half a
decade ago because they were too impractical/unreliable/troublesome.
Which means most will have solved cross-browser Applet interaction
issues by never attempting to use Applets in/on a browser.
 
R

Richard Maher

Hi Jeremy,
Rather than try to learn the ins and outs of document.write, I would
*strongly* suggest that learn proper DOM usage as well.

Can you please provide the "proper DOM" for the following Applet definition.
The navigator.appName has to have c.l.js regulars barfing up their
cornflakes, but it's what I've got from one of SUN's websites, although I'm
honestly very happy to change to something that's "better".

The following is from CORNUCOPIAE.HTML and can be found at
http://manson.vistech.net/t3$examples/

To see the application in action click on: -
http://manson.vistech.net/t3$examples/demo_client_web.html

Username: TIER3_DEMO
Password: QUEUE

Enter "*" for the Queue_Name and then click Get_Job_info.

Cross browser Applet invocation cannot be ignored in these discussions
surely?

Cheers Richard Maher

<script type="text/javascript">

var appletDef = navigator.appName;

if (appletDef == "Microsoft Internet Explorer")
document.write
(
'<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ',
'width= "0" height= "0" name="CornuCopiae"
id="CornuCopiae">',
'<param name="archive" value="tier3.jar">',
'<param name="codebase"
value="http://manson.vistech.net/t3$examples/">',
'<param name="code"
value="CornuCopiae">',
'<param name="mayscript" value="yes">',
'<param name="scriptable" value="true">',
'<param name="name"
value="CornuCopiae">',
'<param name="PORT" value="5255">',
'<param name="HOSTCHARSET" value="ISO-8859-1">',
'<param name="MAXBUF" value="510">',
'<param name="APPLICATION" value="DEMO">',
'<param name="FORM_NAME"
value="queue_lookup">',
'<param name="SSL_REQD" value="N">',
'</object>'
);
else
document.write
(
'<object classid="java:CornuCopiae.class" ',
'type="application/x-java-applet"
archive="http://manson.vistech.net/t3$examples/tier3.jar"',
'width= "0" height= "0" name="CornuCopiae"
id="CornuCopiae">',
'<param name="archive" value="tier3.jar">',
'<param name="codebase"
value="http://manson.vistech.net/t3$examples/">',
'<param name="code"
value="CornuCopiae">',
'<param name="mayscript" value="yes">',
'<param name="scriptable" value="true">',
'<param name="name"
value="CornuCopiae">',
'<param name="PORT" value="5255">',
'<param name="HOSTCHARSET" value="ISO-8859-1">',
'<param name="MAXBUF" value="510">',
'<param name="APPLICATION" value="DEMO">',
'<param name="FORM_NAME"
value="queue_lookup">',
'<param name="SSL_REQD" value="N">',
'</object>'
);

</script>
 
R

Richard Maher

Henry said:
On Jan 7, 12:56 pm, Richard Maher wrote:

<snip>

Weren't Applets generally abandoned in public web site use half a
decade ago because they were too impractical/unreliable/troublesome.
Which means most will have solved cross-browser Applet interaction
issues by never attempting to use Applets in/on a browser.

No.

Were you quoting someone or some event? Or just discussing how you don't
like black people? (Or people who wear shoulder-pads, or blue and green
unless there's something in-between?)

Regards Richard Maher
 
R

Richard Maher

Applets were generally abandoned

Bollocks!

What are you - Andrew Thompson in disguise?
for client-side use.

Surely other Applet deployment options would appear limited?

Look, if Henry's personal prejudices and opinion are that no one in the
world is using Applets then that's great for Henry. Otherwise please provide
a reference for Applet-deprecation at the Sun website (Or Apple, or IBM, or
Mozilla)

Regards Richard Maher

Henry wrote in message

No.
<snip>

No? Applets were generally abandoned for client-side use.
 
J

Jeremy J Starcher

Hi Jeremy,


Can you please provide the "proper DOM" for the following Applet
definition. The navigator.appName has to have c.l.js regulars barfing up
their cornflakes, but it's what I've got from one of SUN's websites,
although I'm honestly very happy to change to something that's "better".

I don't have my own code right now, (wrong computer) but last time I had
to use embed an applet I used the MSIE conditional comments. It was
something like this:

http://forum.jupload.biz/thread.php?threadid=416

Has the advantage it works when Java is available but JS is not.
 
V

VK

I don't have my own code right now, (wrong computer) but last time I had
to use embed an applet I used the MSIE conditional comments. It was
something like this:

http://forum.jupload.biz/thread.php?threadid=416

Has the advantage it works when Java is available but JS is not.

document.write for adding Java applets on the page is all another
matter. As such <applet> or <object> elements do not require any
JavaScript to insert them into page - just like any other element one
can simply use appropriate HTML tags. JavaScript-based workarounds are
caused by the infamous Eolas patent limitation, so to avoid the
necessity of the initial "click to activate" from the user yet do not
formally violate the patent.

Google for "Eolas patent", see for instance
http://www.devx.com/webdev/Article/18063/1954
also see my detailed post of 2006 at
http://groups.google.com/group/comp.lang.javascript/msg/896a73f47ae1ed89
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top