Solved

how to change document background with mousedown event

Posted on 2009-05-14
5
193 Views
Last Modified: 2013-11-19
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
Comment
Question by:hatem_from_mesr
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
sam2912 earned 500 total points
ID: 24383836

<h1 onmousedown="document.body.style.backgroundColor='#880000';">

   Click this page to turn it pink!

</h1>

Open in new window

0
 
LVL 14

Assisted Solution

by:sam2912
sam2912 earned 500 total points
ID: 24383855
#880000 will give you red. Try #DD9999 instead.
0
 

Author Closing Comment

by:hatem_from_mesr
ID: 31581390
thanks man
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24384240
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24384247
ok, too late...
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now