this is the function

<SCRIPT TYPE="Text/JavaScript">
<!-- Beginning of JavaScript -

function changecolor(code) {

document.bgColor=code
}
// - End of JavaScript - -->
</SCRIPT>

this is the code

<a href="" onmouseover="document.bgColor='turquoise'">C</a>
<a href="" onmouseover="document.bgColor='pink'">h</a>
<a href="" onmouseover="document.bgColor='blue'">o</a>
<a href="" onmouseover="document.bgColor='red'">o</a>
<a href="" onmouseover="document.bgColor='yellow'">s</a>
<a href="" onmouseover="document.bgColor='green'">e</a>
<a href="" onmouseover="document.bgColor='white'">your</a> 
<a href="" onmouseover="document.bgColor='greem'">o</a>
<a href="" onmouseover="document.bgColor='seagreen'">w</a>
<a href="" onmouseover="document.bgColor='magenta'">n</a>
<a href="" onmouseover="document.bgColor='fusia'">b</a>
<a href="" onmouseover="document.bgColor='purple'">a</a>
<a href="" onmouseover="document.bgColor='navy'">c</a>
<a href="" onmouseover="document.bgColor='royalblue'">k</a>
<a href="" onmouseover="document.bgColor='Skyblue'">g</a>
<a href="" onmouseover="document.bgColor='brown'">r</a>
<a href="" onmouseover="document.bgColor='almond'">o</a>
<a href="" onmouseover="document.bgColor='coral'">u</a>
<a href="" onmouseover="document.bgColor='olivedrab'">n</a>
<a href="" onmouseover="document.bgColor='teal'">d</a>
<a href="" onmouseover="document.bgColor='black'">color!</a>

i want to change background color of the page. used this codes but it dont work. i dont know where go wrong. pls help.

Recommended Answers

All 3 Replies

Since you are declaring a function in your script, you need to call that function and sending the color value.

onmouseover="changecolor('blue')"

Then in the function

document.body.style.backgroundColor=code;

Since you are using anchor elements, you may want to remove the page loading function of the link in case the user clicks on it.

<a href="javascript: void(0)">I am not clickable</a>

Thank u JorgeM for the help.. =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.