Thursday, November 15, 2007

Simple Scripts In Html And Javascript

Simple Scripts In Html And Javascript
Simple Scripts In Html And Javascript

like in the topic, here is a description how to change the Backgroundcolor “On The Fly”, by klicking on a button or radio-box

first, we ned the html-and body-tags, create a new html-file on your desktop and write the following:

Code:









browser interpretation:
html - tag means “hey, browser, here comes HTML”
in the body-tag you define the looking of your site. you can add things like “bgcolor” for the background, “text” for the textcolor and link / alink / hlink / vlink to define the linkcolor
()

the scripttag is the tag, we’ll need now (sorry, but my english isn’t very well)

modify your file and type in the SCRIPT - TAG:

Code:

function bgcsel(color){
document.bgColor=color;
}

this is the function, witch will change the bgcolor. now we’ll type the rest, to let the function go:
write between the html tags

Code:

switch to Orange

switch to Red

switch to Black

now, when you look at the site andd klick on a radiobutton, the bgcolor will change

BTW: try to replace the “onClick” by “onMouseover”

the final file looks like this:

Code:









simple color changer