473,732 Members | 2,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.write and buffer data

Hi

It's very interesting problem. I couldn't even find any inforamtion
about it on the google.
I think that the best way of explain will be this simple example:

<html>
<body>
<script language="JavaS cript" type="text/javascript"
src="write.js"> </script>
</body>
</html>

write.js:
document.write( "start<br />\n");
document.write( "<" + "script language='JavaS cript'
type='text/javascript' src='test.js'>< " + "/script>");
document.write( "end<br />\n");

and test.js:
document.write( 'middle <br />');
The expected output is:
start
middle
end

but the real output is:
start
end
middle

This output has to be generated inside "write.js" file and I have to
use sometimes some external files like this "test.js".
I'm trying to find a solution to force a browser to output everything
from test.js before the "end".

I found only this info:
http://www.web-developer-india.com/w...t/refp_95.html
where I found that placing HTML tag (without JavaScript) force a
browser to output the buffer. But unfortuanetly I couldn't output any
HTML tag inside write.js file.

Is it possible to force a browser to render the content before "end"
document.write?
Jul 23 '05 #1
12 3342
"Radek Maciaszek" <ra************ *@gmail.com> wrote in message
news:39******** *************** ***@posting.goo gle.com...
Hi

It's very interesting problem. I couldn't even find any inforamtion
about it on the google.
I think that the best way of explain will be this simple example:

<html>
<body>
<script language="JavaS cript" type="text/javascript"
src="write.js"> </script>
</body>
</html>

write.js:
document.write( "start<br />\n");
document.write( "<" + "script language='JavaS cript'
type='text/javascript' src='test.js'>< " + "/script>");
document.write( "end<br />\n");

and test.js:
document.write( 'middle <br />');
The expected output is:
start
middle
end

but the real output is:
start
end
middle

This output has to be generated inside "write.js" file and I have to
use sometimes some external files like this "test.js".
I'm trying to find a solution to force a browser to output everything
from test.js before the "end".

I found only this info:
http://www.web-developer-india.com/w...t/refp_95.html
where I found that placing HTML tag (without JavaScript) force a
browser to output the buffer. But unfortuanetly I couldn't output any
HTML tag inside write.js file.

Is it possible to force a browser to render the content before "end"
document.write?


Is ASP an option?

If so then you could use the FileSystemObjec t to merge the includes.
Jul 23 '05 #2
"McKirahan" <Ne**@McKirahan .com> wrote in message news:<Rr******* *************@c omcast.com>...

Is ASP an option?

If so then you could use the FileSystemObjec t to merge the includes.


I have PHP on server but unfortunately I couldn't use it in this case
because HTML, write.js and test.js are on three different servers. So
for example I could include "write.js" by PHP but I don't know if
write.js return just a "document.write " or will try to include
"test.js" or any other js file. And I couldn't change these
requirements... So the only solution (IMO) is to force a browser to
finish rendering everything before the "end" tag but there is no such
possibility in pure JavaScript in IE nor in Mozilla. I hope I am
wrong..
Jul 23 '05 #3
With Ultimater help I've found a solution to this problem. Just fight
a fire with a fire.

document.write( "<script src='start.js'> \</script>");
document.write( "<script src='test.js'>\ </script>");
document.write( "<script src='end.js'>\</script>");

here is the link:
http://www.webdeveloper.com/forum/sh...ad.php?t=61386

cheers
Radek
Jul 23 '05 #4
Radek Maciaszek wrote on 04 apr 2005 in comp.lang.javas cript:
With Ultimater help I've found a solution to this problem.


What problem?

Without your quoting of the posting you are reacting on,
how the hell should we know what you are talking about?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #5
"Evertjan." <ex************ **@interxnl.net > wrote in message news:<Xn******* *************@1 94.109.133.29>. ..
Radek Maciaszek wrote on 04 apr 2005 in comp.lang.javas cript:
With Ultimater help I've found a solution to this problem.


What problem?

Without your quoting of the posting you are reacting on,
how the hell should we know what you are talking about?


I'm sorry. I just didn't want to quote all the long post. But if you
go to this link: http://www.webdeveloper.com/forum/sh...ad.php?t=61386
you will find the problem and the answer :)

cheers
Radek
Jul 23 '05 #6
Radek Maciaszek wrote on 05 apr 2005 in comp.lang.javas cript:
"Evertjan." <ex************ **@interxnl.net > wrote in message
news:<Xn******* *************@1 94.109.133.29>. ..
Radek Maciaszek wrote on 04 apr 2005 in comp.lang.javas cript:
> With Ultimater help I've found a solution to this problem.


What problem?

Without your quoting of the posting you are reacting on,
how the hell should we know what you are talking about?


I'm sorry. I just didn't want to quote all the long post. But if you
go to this link:
http://www.webdeveloper.com/forum/sh...ad.php?t=61386 you will find
the problem and the answer :)


This is usenet, so please conform to usenet practices, Radek.

Don't make us use a newbie technology like the web for that.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #7
Radek Maciaszek wrote:
document.write( "<script src='start.js'> \</script>");
document.write( "<script src='test.js'>\ </script>");
document.write( "<script src='end.js'>\</script>");
Firstly, don't call document.write( ) consecutively if you can avoid it.
Doing otherwise is known to be error-prone, and inefficient compared to
the alternative(s).

Secondly, you don't have to escape the `<' character, but you should escape
the `</' (ETAGO delimiter) with `<\/' if these statements are part of a
HTML document (note that document.write( ) is not supposed to work in XHTML,
you have to use W3C DOM Level 2+ Methods there).

Thirdly, your `script' elements are lacking the `type' attribute, required
for Valid (X)HTML 4.01/1.0+.

Use instead:

var
scripts = new Array("start.js ", "test.js", "end.js"),
s = "";

for (var i = 0; i < scripts.length; i++)
{
s += '<script type="text/javascript" src="'
+ scripts[i]
+ '"><\/script>\n';
}

document.write( s);

However, note that your method using `scripts' element alone may not work
as expected. But if you concatenate the output strings to be generated,
your original problem should disappear. Yet, making your document dependent
on client-side scripting this way, could raise usability issues, depending
on the expected environment it should run.
here is the link:
http://www.webdeveloper.com/forum/sh...ad.php?t=61386


Alas, there are no competent people there. Not a surprise to me, though.
PointedEars
--
Das Netz ist Freude. Es ist Ekstase, die jeden einzelnen Nerv erglühen
läßt. Es ist Duft, den man fühlt. Es ist ein Bild, das man riecht. Es
ist Erfüllung - ein Geschmack, neben dem alles andere schal ist.
-- "Netzreiter-Preisung" aus "Der Netzparasit" von Andreas Brandhorst
Jul 23 '05 #8
It doesn't matter where you break your End Script tags.

The left-than-character doesn't need to be escaped, but neither does the
forward-slash.

document.write( "<script src='start.js'> \</script>");
is the same as:
document.write( "<script src='start.js'> <\/script>");

You Simply cannot Write it out: </script> or you will actually end the
"real" SCRIPT tag.
Yeah, the script tags are lacking the TYPE attribute...
They are also lacking the LANGUAGE attribute.
Even though the LANGUAGE attribute is deprecated in the newer browsers,
it doesn't mean that older browsers don't still use it, because they do.
It's best to include both of the attributes.
(note: deprecated means that it is no longer supported and kinda
abandoned)
Thus:
document.write( "<script type="text/javascript" language="javas cript"
src='start.js'> \</script>");

*** Sent via Developersdex http://www.developersdex.com ***
Jul 23 '05 #9
Kevin Yarmak wrote:
It doesn't matter where you break your End Script tags.
Yes, it does.

[snip]
document.write( "<script src='start.js'> \</script>");
is the same as:
document.write( "<script src='start.js'> <\/script>");
In so far as an ECMAScript parser is concerned, yes, but not from the
point of view of an SGML parser. The HTML specification states that a
user agent is permitted to terminate a SCRIPT element on the first
occurance of ETAGO (</). Even though no-one knows of a user agent that
does this, breaking this token with a backslash will prevent markup
validators from issuing errors on every occurance.

Of course, if you place the script in an external file, which is surely
where the bulk of any script should go in most cases, how an SGML parser
behaves is of no consequence; no escaping is required at all.

[snip]
They are also lacking the LANGUAGE attribute.
Even though the LANGUAGE attribute is deprecated in the newer browsers,
it doesn't mean that older browsers don't still use it, because they do.
Not in any way that is really desirable or necessary.
It's best to include both of the attributes.


I strongly disagree.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7386
by: Ellixis | last post by:
Hello, How can I use fwrite() and fseek() in order to write data in the middle (or anywhere else) of a file without overwriting existing data ? People told me that I should load the file into memory (a variable) and use concatenation. But, according to me, It isn't clean to load an entire file into
14
4122
by: Eli | last post by:
I've got a script that I'm trying to debug which uses document.write() to place HTML within a page. In both IE6 and Firefox when I view source, I see only the script itself and not any HTML as it's being written into the page. Is there a way that I can view what is being placed into the page, instead of, or in addition to the javascript code?
1
5509
by: Jeff Weber | last post by:
First, my question: Should I use Write or BeginWrite (sync or async) to stream data to my clients. Details: On the server I have a custom circular data buffer that receives byte array data representing data structures at a rate of 30ms. On a thread seperate from that which Enqueues data to the buffer I have a high performance timer that Dequeues data from the custom buffer and sends it via a tcpClient connection to the client. The...
58
2880
by: jacob navia | last post by:
Hi I have put together a document explaining most extensions of lcc-win32, why they were done, why they could be useful, and a documentation of the string/container library that uses those extensions. This document is not finished but I would appreciate your feedback. jacob
1
1880
by: neoret | last post by:
Hello. I need a helping hand to help me send an unsaved dokument through a POST call. I have added functionality to word and want to send a unsaved document through a POST call. This works fine when I try sending a saved document - refering to the path and using a filstream like this: FileStream fileStream = new FileStream(remoteFolder + filename,
2
7847
by: Andy | last post by:
Hi, I have an XML document that uses namespaces (it is from a Word 2007 file). I want to retrieve all the "t" elements that belong to the "w" namespace (<w:t>) using XPath from VB.NET 2003 (.NET framework 1.1). I've successfully loaded the document into a XmlDocument DOM parser (I can dump the contents using OuterXML). And, I've created a XmlNamespaceManager and assigned it the "w" namespace.
24
4450
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone help out a newbie? #include <stdio.h> #include <ctype.h> #include <string.h>
2
1685
by: cmrhema | last post by:
Hi All , I have with me a server socket program, I am receiving all the clients, but what happens is i have to write it into a file. This consumes time. So we do not have a data loss, but as the time taken to write into the log file increases, some of the data does not get written. This is the code //ONLY SHOBA
1
4454
by: Almund | last post by:
Hi, I'm trying to implement streaming over http and got stuck with a problem trying to send chunks of data using the .Net NetworkStream object. All works fine as long as I send the entire data in one invocation to the NetworkStream, like: _stream.Write(buffer, 0, buffer.Length) But if i try:
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.