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
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #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,075
    Thanks
    0
    Thanked 256 Times in 252 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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #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,075
    Thanks
    0
    Thanked 256 Times in 252 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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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