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
Solved

how to change document background with mousedown event

Posted on 2009-05-14
5
200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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…

839 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