• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

how to change document background with mousedown event

hi all,
my manager wants me to change the document background with mouse click
the sample does not work with me
could you please correct it for me

best regards
hatem gamal
<html>
    <head>
        <title>
            JavaScript Event Example
        </title>
    </head>
 
    <body id="n" name="n" bgcolor="#eeeeee" >
        <h1 onmousedown="var obj=document.getElementById("n");obj.bgcolor='#880000';">
            Click this page to turn it pink!
        </h1>
    </body>
</html>

Open in new window

0
hatem_from_mesr
Asked:
hatem_from_mesr
  • 2
  • 2
2 Solutions
 
sam2912Commented:

<h1 onmousedown="document.body.style.backgroundColor='#880000';">
   Click this page to turn it pink!
</h1>

Open in new window

0
 
sam2912Commented:
#880000 will give you red. Try #DD9999 instead.
0
 
hatem_from_mesrAuthor Commented:
thanks man
0
 
Michel PlungjanIT ExpertCommented:
this is how you can click on the page to change the color

<script>
window.onload=function() { document.onmousedown=function() { document.body.style.backgroundColor='pink' } }
</script>


0
 
Michel PlungjanIT ExpertCommented:
ok, too late...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now