Click to See Complete Forum and Search --> : Clearing a page in javascript


Seano
11-23-2003, 08:32 PM
does anyone know any way in which i can clear the contents of a HTML page using javascript? I need this badly!

Thanks a lot
Sean

fredmv
11-23-2003, 08:36 PM
document.open();

pyro
11-23-2003, 08:36 PM
document.write("") might work, depending what you need... Sounds like a bit of an odd request.

Seano
11-23-2003, 08:38 PM
Sorry ill try to explain myself a little better
This is what ive got going on:

Ive got an XML document which has to be sorted in a table.
Each time the user clicks a heading it sorts in asc then desc order.

What im doing is that each time the user clicks im calling an XSL document that contains some javascript stuff which works fine, However the only problem is that from within the XSL document, whenever the user clicks a heading the table appears at the end of the current table and not in a new page like it did in the HTML document.

so basically what im after is if it is possible for me to clear the current window and then write to it, rather than writing into a window filled already with text?

Sean

ray326
11-23-2003, 08:40 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Conforming HTML 4.01 Transitional Template</title>
<link rel="stylesheet" type="text/css" href="" />
<style type="text/css">
</style>
</head>
<body>
<p>does anyone know any way in which i can clear the contents of a HTML page using javascript? I need this badly!
</p>
<p>Thanks a lot</p>
<p>Sean</p>
<script language="Javascript">
alert(document.body.innerHTML);
document.body.innerHTML = "";
</script>
</body>
</html>

Seano
11-23-2003, 08:45 PM
mate your a legend.
also thanks for the massive alert smartarse :D

haha all good thanks