...

View Full Version : this.style.background no-repeat



quentin
05-30-2005, 10:32 AM
I am using >>>

onmouseover="this.style.background='url(images/btns/btn_over.gif)';"

how can i add a no-repat and 50% 50% position ?

thank you

glenngv
05-30-2005, 10:37 AM
http://www.devguru.com/Technologies/css/quickref/css_background.html

quentin
05-30-2005, 10:28 PM
you mean this code :

onmouseover="this.style.background='url(btn_over.gif) no-repeat 50% 50%';" onmouseout="this.style.background='url(btn.gif) no-repeat 50% 50%';"

should work ?

thank you

glenngv
05-31-2005, 05:32 AM
Yes, try it. But you can accomplish the same thing with pure CSS and no javascript at all.


<style type="text/css">
element:hover{
background:url(btn_over.gif) no-repeat 50% 50%;
}
element:hover{
background:url(btn.gif) no-repeat 50% 50%;
}
</style>
You can use :hover and :active pseudo-classes to any element except in IE where those are only applicable to links. But there's a fix (http://www.vladdy.net/demos/iepseudoclassesfix.html) for IE without putting onmouseover and onmouseout handlers to each element.

quentin
05-31-2005, 08:02 PM
I dont need CSS code I need javascript code
CSS is not a problem

thank you

glenngv
06-01-2005, 08:07 AM
Javascript is more often disabled than CSS. So if you rely on pure Javascript solution and javascript is disabled or not supported by the browser, the functionality is lost. Moreover, CSS solution is easier to implement. You don't have to attach onmouseover and onmouseout handlers for all the elements. You just declare it one time in CSS and automatically the behavior is applied to all the elements.

It's your choice, I'm just suggesting an easier and better alternative solution.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum