Javascript-generated mandelbrot set

Note 1: This scripts uses the trick of creating a table with as many cells as requested "pixels" in the "image", coloring the backgrounds of the cells accordingly. This makes it really heavy to browsers to show, so there will probably be a considerable delay for the "image" to show up.

Note 2: The calculation of the Mandelbrot set takes some time and most browsers will completely lock-up during these calculations. So don't worry if the browser stops responding for some amount of time (usually less than a minute in a fast computer). If you increase the dimensions of the "image" to be calculated, the calculation time will increase accordingly; even for the default 100x100 image it takes some time even in a fast computer.

Note 3: The script uses a 1x1 transparent gif like this.

<html>
<head><title>Javascript graphical mandelbrot set</title>
<script LANGUAGE="JavaScript">
<!--
function Mandelbrot()
{
    var Width = 100;
    var Height = 100;
    var Iters = 15;
    var Zoom = "4";

    document.writeln("<table border=0 cellspacing=0 cellpadding=0>");
    for(y=0; y<=Height; ++y)
    {   var Im = -1.5+3*y/Height;
        document.writeln("<tr>");
        for(x=0; x<=Width; ++x)
        { var Re = -2+3*x/Width;
            var Zr = Re;
            var Zi = Im;
            var n = 0;
            for(; n<=Iters; n++)
            {   var Zr2 = Zr*Zr;
                var Zi2 = Zi*Zi;
                if(Zr2+Zi2 > 4) break;
                Zi = 2*Zr*Zi+Im; Zr = Zr2-Zi2+Re;
            }
            if(n>Iters) n=0;
            var c1 = (n<Iters/2 ? Math.round(255*2*n/Iters) : 255);
            var c2 = (n>=Iters/2 ? Math.round(255*2*(n-Iters/2)/Iters) : 0);
            var num1 = (c1<10 ? "0" : "")+Number(c1).toString(16);
            var num2 = (c2<10 ? "0" : "")+Number(c2).toString(16);
            document.write("<td bgcolor=\""+num1+num2);
            document.writeln("00\"><img src=\"p.gif\" border=0 width="+Zoom+" height="+Zoom+"></td>");
        }
        document.writeln("</tr>");
    }
    document.writeln("</table>");
    document.close();
}
// -->
</SCRIPT>
</head>

<body>

<h2>Javascript-generated mandelbrot set</h2>

<form name=Frm><input type=button value="Proceed" onClick="Mandelbrot()"><br>
</form>

</body>
</html>