Solved

how to change document background with mousedown event

Posted on 2009-05-14
5
201 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

756 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