[Contents] [Previous] [Next] [Index]

flush

Sends data from the internal buffer to the client.

Server-side function

Implemented in

LiveWire 1.0

Syntax

flush()

Parameters

None.

Description

To improve performance, JavaScript buffers the HTML page it constructs. The flush function immediately sends data from the internal buffer to the client. If you do not explicitly call the flush function, JavaScript sends data to the client after each 64KB of content in the constructed HTML page.

Use the flush function to control when data is sent to the client. For example, call the flush function before an operation that creates a delay, such as a database query. If a database query retrieves a large number of rows, you can flush the buffer after retrieving a small number of rows to prevent long delays in displaying data.

Because the flush function updates the client's cookie file as part of the HTTP header, you should perform any changes to the client object before flushing the buffer, if you are using client cookie to maintain the client object. For more information, see Writing Server-Side JavaScript Applications. Do not confuse the flush method of the File object with the top-level flush function. The flush function is a top-level server-side JavaScript function that is not associated with any object.

Examples

The following example iterates through a text file and outputs each line in the file, preceded by a line number and five spaces. The flush function then causes the client to display the output.

while (!In.eof()) {
   AscLine = In.readln();
   if (!In.eof())
      write(LPad(LineCount + ": ", 5), AscLine, "\n");
   LineCount++;
   flush();
}

See also

write


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 16:38:00


Copyright © 1997 Netscape Communications Corporation