how do I 'clear screen''

J

John

Hi

I have the following in a Perl script. I just want to "clear screen" but it
does not work.
I don't think I've got my client and server sides confused.

Any ideas?

<SCRIPT Language="JavaScript">
moveTo (0,0);
</SCRIPT>

Thank you
John
 
D

David Dorward

John said:
I have the following in a Perl script. I just want to "clear screen" but
it does not work.

JavaScript doesn't have a "clear screen" as such. What is the screen anyway?
Its not often you see JavaScript running in a console window.

In a browser you generally have an HTML document, which JavaScript can
modify. I suppose deleting all the child nodes of the body element could be
thought of as clearing the screen.

<SCRIPT Language="JavaScript">

This is HTML 3.2. The language attribute was deprecated and replaced with
the type attribute about a decade ago.
moveTo (0,0);

This, IIRC, attempts to move the browser window about on screen. Thankfully
most browsers seem to come with options to selectively disable that bit of
JS these days. Its very irritating.
 
V

VK

John said:
Hi

I have the following in a Perl script. I just want to "clear screen" but it
does not work.

If I was a nasty guy, I would say that try to learn a language by just
inserting random made up commands (like moveTo used to move browser
window) and then see the results is a *very* long learning curb with a
high risk of no success. If I was really nasty, I would finish it by
"read the damn manual" ;-)

As I am not such guy:
JavaScript has no build-in means to accept input and show output. It
can do it only through the methods of host objects (browser DOM in most
cases). If you want to "try the water" with JavaScript, you can use a
form textarea for output for your script.

<html>
<head>
<title>Hello world</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function init() {
var out = document.forms[0].elements['output'];
for (var i=0; i<3; i++) {
out.value+= 'Hello world' + '\n';
}
// out.value = ''; // will "clear the output"
}

window.onload = init;
</script>
</head>

<body>
<form method="post" action="">
<textarea name="output" cols="70" rows="20"></textarea>
</form>
</body>
</html>
 
S

scriptguru

John напиÑав:
Hi

I have the following in a Perl script. I just want to "clear screen" butit
does not work.
I don't think I've got my client and server sides confused.

Any ideas?

<SCRIPT Language="JavaScript">
moveTo (0,0);
</SCRIPT>

Thank you
John
you can use one of this commands:

location.replace("about:blank")
// or
document.body.innerHTML=""
//or
setTimeout("document.write('')",100)

All of them works, but are almost completaly useless ;)
Maybe you should consider what you want exactly?

Val
 
J

John

Many thanks, everyone.

Yes, the document.body.innerHTML="" was the answer.

Many thanks.

Much appreciated.

John



John ???????:
Hi

I have the following in a Perl script. I just want to "clear screen" but
it
does not work.
I don't think I've got my client and server sides confused.

Any ideas?

<SCRIPT Language="JavaScript">
moveTo (0,0);
</SCRIPT>

Thank you
John
you can use one of this commands:

location.replace("about:blank")
// or
document.body.innerHTML=""
//or
setTimeout("document.write('')",100)

All of them works, but are almost completaly useless ;)
Maybe you should consider what you want exactly?

Val
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top