Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Dynamically Change The Background Image On Mouse Effects!, easy code to dynamically change the background image
shiv
post Mar 21 2006, 12:02 AM
Post #1


Member [ Level 2 ]
Group Icon

Group: Members
Posts: 53
Joined: 20-March 06
Member No.: 12,139



stun ur visitor with a new bg image on every mouse click of his!

easy code to dynamically change the background image.



QUOTE
control the background image using the links on your site. control the color using onMouseOver, onMouseOut, onClick, and a combination of all of them.

place the code below between the and tags within the HTML page where you want the link to appear. edit the link text provided to point at the page you would like to open.



Option 1:
use this to change the background color when user places mouse over the link.


CODE
<a href="link.htm" onMouseOver="document.body.background='red.gif'">Link Text</a>



Option 2:
use this to change the background image when user removes mouse from over the link (onMouseOut).

CODE
<a href="link.htm" onMouseOut="document.body.background='green.gif'">Link Text</a>



Option 3:
use this to change the background image when user clicks the link (onClick).

CODE
<a href="link.htm" onClick="document.body.background='blue.gif'">Link Text</a>




Option 4:
use this to change the background image twice, once when the user places the mouse over the link then again when the user takes the mouse off the link (onMouseOver and onMouseOut).

CODE
<a href="link.htm" onMouseOver="document.body.background='red.gif'" onMouseOut="document.body.background='green.gif'">Link Text</a>



Option 5:
use this to change the background image three times, once when the user places the mouse over the link, again when the user takes the mouse off the link, and again when the user clicks on the link (onMouseOver, onMouseOut, and onClick).


CODE
<a href="link.htm" onMouseOver="document.body.background='red.gif'" onMouseOut="document.body.background='green.gif'" onClick="document.body.background='blue.gif'">Link Text</a>



njoy!

shiv
Go to the top of the page
 
+Quote Post
Jack Cheng
post Mar 21 2006, 10:05 PM
Post #2


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 12
Joined: 16-February 06
Member No.: 11,335



It is nice, but is there any other applicable uses to this other than to irritate your users with crazy, inconsistent, and confusing backgrounds?
Go to the top of the page
 
+Quote Post
iGuest
post Dec 13 2007, 09:41 PM
Post #3


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



If it could change the background image of a DIV, I can see a use for it. Anyone have any code for that?

-Lance
Go to the top of the page
 
+Quote Post
iGuest
post Jun 27 2008, 08:31 AM
Post #4


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



Wouldn\\
Dynamically Change The Background Image On Mouse Effects!

I'm useless at javascript, but wouldn't it be something like

OnClick="this.Style.Background='red.Gif'"

But after trying that, it didn't work :P anyone have a quick solution to changing a style element directly through an 'on' command without having to use your own functions?

I'm currently trying to make a 'pushed-look' to my CSS buttons using onClick.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Javascript: Disable Mouse Right-click In Browser(16)
  2. Let Visitors Bookmark Ur Site To Get Repeat Visitors!(1)
  3. Change Table Colors On Mouse Effects!(8)
  4. Unobtrusive Javascript Image Rollovers(0)
  5. Enlarge Image Script(19)
  6. Google Map Like Pins On Image(4)
  7. Problems With Dynamically Loading Javascript(2)
  8. Problem With Form Elements(3)
  9. Get Mouse Position(4)
  10. Problems Dynamically Adding A Table With Dom(4)


 



- Lo-Fi Version Time is now: 22nd August 2008 - 12:45 AM