Simple JS Interpretter: Here's a small web page you can use to test JavaScript code.

posted 2000-Mar-29

One day someone on IRC (#javascript) asked how to convert '500px' to 500. I said that I thought parseInt() would work, but wasn't sure.

I frequently need a quick way to just run a bit of javascript code and see the result. I know you can do this in Netscape's javascript console, but I use IE as my main browser.

Following is a very simple HTML page which allows you to enter JavaScript code into a form and see the results. The last evaluated value gets alerted to you, so just entering:


yields an alert of '500' (I was right! Yay!).

Change JS code below, and tab out of the field for your result:

However, you can also enter more complex code, even including functions. e.g.

function sq(x){
   return (x*x);

alerts you with '625'
var msg = "";
for (var i=0; i<10; i+=2){
  msg += (i+"\r");
gives a list of numbers from 0 to 8. And so on.

The simple page, which can be stored locally and bookmarked:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">
<head><title>JavaScript Evaluator</title></head>
<body onLoad="document.forms[0].elements[0].select()">
<form onsubmit="return false" action="#" method="get">
Change JS code below, and tab out of the field for your result:<br>
<textarea onchange="alert(eval(this.value))" rows="10" cols="80">
var foo = "Hello";
foo +=" World";
<!-- written by Gavin Kistner : -->
Gavin Kistner
04:11PM ET
See for a better version.
net.mind details other résumé contact