CommandArea

The CommandArea object is another a command line interface for javascript, within a web page. All internal functionality is identical to the CommandPrompt. The only difference is how you enter the javascript commands. Instead of having a textbox, and listening for the kepress event on the enter key, The CommandArea object uses a multiline textarea control, to allow you to inject longer code chunks and values. It is also built so that it can easily be added to any page. From within the CommandArea, you can also call any javascript command, get or set the value of any existing variable within the page, or evaluate expressions. One thing to keep in mind is that functions defined within the CommandArea are only accessible during code execution. For example, if you define a function within the CommandArea and execute it, then go and change the contents of the CommandArea... your function will be gone.

An instance of the CommandArea object can be created as easily as this:
<script>
	var cmdArea = new CommandArea();
</script>
...And it is also written such that there can be multiple instances of the CommandArea per browser instance.

Try typing any javascript code into the text box on the CommandPrompt and see what happens. Here are some examples of what you can type (and then hit enter)...
  • alert('foo');
  • function helloworld(){alert('HELLO WORLD'); return "goodbye world..."; }helloworld();
Try Me!
Untitled Document