how do I 'clear screen''

Discussion in 'Javascript' started by John, Sep 19, 2006.

  1. John

    John Guest

    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
     
    John, Sep 19, 2006
    #1
    1. Advertising

  2. John wrote:

    > 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.

    <http://w3.org/DOM/DOMTR/>

    > <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.


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Sep 19, 2006
    #2
    1. Advertising

  3. John

    VK Guest

    John wrote:
    > 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>
     
    VK, Sep 19, 2006
    #3
  4. John

    Guest

    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
     
    , Sep 20, 2006
    #4
  5. John

    John Guest

    Many thanks, everyone.

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

    Many thanks.

    Much appreciated.

    John


    <> wrote in message
    news:...

    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
     
    John, Sep 22, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad

    Clear all fields on a screen

    tshad, May 19, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,283
    tshad
    May 20, 2005
  2. Boki
    Replies:
    5
    Views:
    11,625
    Darryl Pierce
    Apr 16, 2005
  3. owl
    Replies:
    2
    Views:
    880
  4. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,036
    Mark Fitzpatrick
    Jan 31, 2008
  5. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    971
    Steven Cheng[MSFT]
    Mar 6, 2007
Loading...

Share This Page