Change background color when you double-click


script>

function makeRandom(range) {
rand=Math.floor(range*Math.random())
return rand
}

function makeHexa(thiscol) {
var colhex_left = Math.floor(thiscol/16)
var colhex_right= thiscol-(colhex_left*16)
if (colhex_left == 10) {colhex_left=”A”}
if (colhex_left == 11) {colhex_left=”B”}
if (colhex_left == 12) {colhex_left=”C”}
if (colhex_left == 13) {colhex_left=”D”}
if (colhex_left == 14) {colhex_left=”E”}
if (colhex_left == 15) {colhex_left=”F”}
if (colhex_right == 10) {colhex_right=”A”}
if (colhex_right == 11) {colhex_right=”B”}
if (colhex_right == 12) {colhex_right=”C”}
if (colhex_right == 13) {colhex_right=”D”}
if (colhex_right == 14) {colhex_right=”E”}
if (colhex_right == 15) {colhex_right=”F”}
var colhex =”"+colhex_left+colhex_right
return colhex
}

function dblclick() {
var redcolor=makeRandom(255)
redcolor=makeHexa(redcolor)
var greencolor=makeRandom(255)
greencolor=makeHexa(greencolor)
var bluecolor=makeRandom(255)
bluecolor=makeHexa(bluecolor)
document.bgColor=”"+redcolor+greencolor+bluecolor
}

if (document.layers) {
document.captureEvents(Event.ONDBLCLICK);
}
document.ondblclick=dblclick;

/SCRIPT>


Code : Javascript.
Instruction : Paste code in head section of the page.
Cost : $0.00 (FREE).

Related posts :

  • Change background everyday
  • Change your computer’s settings
  • java.applet.*
  • Background flash java script
  • paint in Java
  • POETRY BOT
  • Applet in Java
  • Leave a Comment