Solved

how to change document background with mousedown event

Posted on 2009-05-14
5
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 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