Please Reload






First Byte












HTML is a code. Javascript is a code.

Byte Budget is javascript

that writes HTML......

We start by telling the browser

that we are going to use javascript:<script>Now we list the "variables"

The variables contain the HTML

we want to write....

This IS case sensitive.

You may name them anything you want.

NOTE: No quotes inside brackets.

But ALWAYS quotes

around the HTML segments.

There are no quotes used for what I call

"nested variables"but that's

another lesson or two away...


var a = "<td bgcolor=red height=20 width=100>";
Write a red td cell 20 high and 100 wide.


var b = "<td bgcolor=white height=20 width=100>";
Write a white td cell 20 high and 100 wide.


var c = "</td></tr><tr>";
Close the td cell and row

and open another row.




Now it's time to write.

You always start with:

with(document){

Now we begin our table.

YES, you can put the actual HTML

code in the write; and we do here

because it is used once.

The variables are used multiple times.

But we write them once

therefore saving BYTES....

write("<center><table cellspacing=0 cellpadding=0>");


Now we actually arrange

our variables to make something.

write(a+c+b+c+a+c+b+c+a+c+b+c+a+c+b+c+a);

This is a "string" and directs the browser

to write the shape above.

a+c+b+csays to write a red cell,close the cell

and row open new row, a white cell,

close the cell and row and open another.

You may make as many rows as you

want by following the pattern.


If we write:

write(a+b+c+a+b+c+a+b+c+a+b);

we would get a row with a red and white

side by side in each row down for four rows....






If we write:

write(a+b+c+b+a+c+a+b+c+b+a);

we would get a row with a red and white

alternating all the way down.




We then end our table

and close the script.

write("</td></tr></table></center>"); } </script>



Your javascript warning goes just

before the closing body tag




There is no room for error here.

PUNCTUATION is very important....

so be aware as

you play with the script...

If you get a white screen

you have an error in punctuation.

If you see the code,

there is an error in the "string".




Here is the code for the above.

CCP it anywhere after your body tag.......

More about placement in future lessons.

Experiment and see what you can do.

but most of all have fun!!