Link to home
Start Free TrialLog in
Avatar of hatem_from_mesr
hatem_from_mesrFlag for Egypt

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Samuel Liew
Samuel Liew
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hatem_from_mesr

ASKER

thanks man
Avatar of Michel Plungjan
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>


ok, too late...