Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    this.style.background no-repeat

    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

  • #2

  • #3
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Yes, try it. But you can accomplish the same thing with pure CSS and no javascript at all.
    Code:
    <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 for IE without putting onmouseover and onmouseout handlers to each element.

  • #5
    New Coder
    Join Date
    Jul 2004
    Location
    france
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I dont need CSS code I need javascript code
    CSS is not a problem

    thank you

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •