HighDots Forums  

Re: newbie - script display problem

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: newbie - script display problem in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pop Tart
 
Posts: n/a

Default Re: newbie - script display problem - 03-09-2008 , 09:06 AM






On Sun, 09 Mar 2008 03:31:07 -0700, VK wrote:

Quote:
"Before document load event document.write only. Ohmmm...
After document load event DOM methods only. Ohmmm..."
so, to write content from javascript to the browser before the document
load event, I need to put script somewhere inside the *body*? Is that
the only way? ie..

<body>
<p>hello world</p>
<script> ...my javascript statements here... </script>
<p> blah blah blah </p>
</body>


Quote:
P.S. Before document load event document.write temporary switches the
input stream from server to script generated instream and after that
continues with the server instream.
After document load event document.write clears any current document
content and replaces it with script generated instream. Simple as a
moo-cow yet keeps breaking many serious "corporate" solutions for over
ten years by now...
Thanks for the tip.

--
Regards,
Pop Tart


Reply With Quote
  #2  
Old   
VK
 
Posts: n/a

Default Re: newbie - script display problem - 03-09-2008 , 05:14 PM






On Mar 9, 4:06 pm, Pop Tart <morespamsREM... (AT) REMOVEgmail (DOT) com> wrote:
Quote:
On Sun, 09 Mar 2008 03:31:07 -0700, VK wrote:

"Before document load event document.write only. Ohmmm...
After document load event DOM methods only. Ohmmm..."

so, to write content from javascript to the browser before the document
load event, I need to put script somewhere inside the *body*? Is that
the only way?
Right. On a higher scale we have here two completely different
concepts: an input stream and a document.

Before load event it is an input stream, so the only thing we can
reliably do is to put the default input stream in buffering mode (data
received but not sent to consumer so accumulated in buffer), start
feeding data from an alternate input stream, then switch back to the
main instream. This is what document.write does on this stage (before
document load). Respectively its usage limited by occasional initial
page content adjustment (plus Eolas workaround for Java applets): so
basically you don't want to use document.write until you really and
fully comfortable with DOM/Jvascript development.

Quote:
After document load event document.write clears any current document
content and replaces it with script generated instream. Simple as a
moo-cow yet keeps breaking many serious "corporate" solutions for over
ten years by now...

Thanks for the tip.
You are welcome. Just this year I already helped this way to many very
serious guys. That is always a pleasure to listen their
"encapsulation, augmentation, OOP paradigm" and other blah-blah for a
few minutes and then just fix it this way :-) Wish you to enjoy this
as well some day :-) You current book still makes me suspicious. David
Flanagan's book is regularly suggested in this group:
http://www.jibbering.com/faq/index.html#FAQ3_1
(honestly I never read him)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.