logo To Foot
© J R Stockton, ≥ 2009-08-02

JavaScript/HTML/VBS Quick Trials.

No-Frame * Framed Index * Frame This
Links within this site :-

See "About This JavaScript Site" in JavaScript Index and Introduction.

This page is primarily for local use, mainly mine.
It may work best in MS IE.

Please do not use this actual Web page repeatedly. If you like it, or parts of it, make your own private page on your private local system, including only what is essential. This page is copyright, and must not be re-published; but you are free to re-implement its concepts. No include files are used; CSS is optional.

This page can be read completely with scripting disabled. But, to get any of the buttons to operate as intended, JavaScript must be enabled. To operate usefully, the VBS button also requires VBScript.

To save my bandwidth, operation or use of this page is now disabled when it is served from my Web site. Use a copy instead; that should work.

The Buttons

"Eval" uses the JavaScript "eval" routine indirectly. Put JavaScript code in the big box, press the button, and see the final result below. The button definition includes onClick="this.form.Result.value=remoteEval_(this.form.Code.value)"

"NewW" uses the JavaScript "eval" routine indirectly. Put JavaScript code using document.write[ln] in the big box, press the button, and see the final result in a new window.

"HTML" uses the "document.write" method. Put HTML code in the big box, press the button, and see the result on a new page. The button definition includes onClick="document.write(this.form.Code.value)"

"VBS" is as HTML, but adds tags for VBScript.

"Pack" packs text paragraphs to the indicated right margin.

"Indt" indents JavaScript (ECMAScript 3; possibly unsafe for later versions) by two spaces per unclosed { } and for some continuing statements.

"Demo" loads trivial examples for "Eval".

"+" & "-" alter textarea height (the width fills the window).

Ignore any "?" button completely.

Operation

Variable F has been set to refer to the blue Form.

Eval

Give in the textarea a JavaScript expression, or expressions, to evaluate; the Result of the last will be shown (for multiple answers, evaluate an array, e.g. r = [x, y, z]).
e.g. Bard = "04/23/1564".replace(/(\d\d).(\d\d).(\d\d\d\d)/, "$3-$1-$2")
or S = "ab6cd@e.f" ; /^.+@.+\..+$/.test(S) to test an E-address with a RegExp
or +F.X2.value + +F.X3.value to do 2+3, etc.
or F.Code.rows=5 ; F.Code.cols=45 to re-size the box.

If code includes document.write[ln] a new page is written; try Back and View Source.

For the final expression to return a Result, it should start with neither var nor a literal RegExp or Array; instead, use such as X = ....

Avoid variable names that might refer to existing objects, fields, or variables, except to refer to those items. To see why not, try Eval of F.Code.value="" or document.forms["F"].Code.value="" or F.Eval.value=88. Names ending with underline are reserved.

NewW

Give some code using document.write().

HTML

Give in the textarea an argument for document.write().

VBS

Give VBScript in the textarea, using document.write or other means of observing the effect.

Pack

Give text in the textarea. Paragraphs are separated by blank lines. Pack may assume DOS line-ends.

Indt

Give ES3 script in the textarea.

Demo

This loads simple demo code, for "Eval", to the textarea. Press again to change demo. Demo 6 is for testing code speed; put the codes to be compared within two of the {} provided.

The Form

Twelve controls below are
F.Code, F.Eval, F.NewW, F.Html, F.Vbs, F.Pack, F.Len, F.Indt, F.Load, F.Bigr, F.Smlr, F.Result
.

For example, to alter the number of rows, enter F.Code.rows = 5 and press the Eval button.
Try document.body.style.backgroundColor = "lime" ; and document.write(document.body.innerHTML) ; and document.body.style.font="normal normal medium Papyrus" ; and F.X0.disabled ^= 1 .

     

                       
This is a div with ID Divn and created for writing to;
Divn.innerHTML=S may suffice, otherwise
document.getElementById("Divn").innerHTML=S.
I cannot with the HTML button create and write into a div.

JavaScript Include Files are no longer used by this page, but JavaScript Demos still has them.

Home Page
Mail: no HTML
© Dr J R Stockton, near London, UK.
All Rights Reserved.
These pages are tested mainly with Firefox 3.0 and W3's Tidy.
This site, http://www.merlyn.demon.co.uk/, is maintained by me.
Head.