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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change the background image of a link

    what i am trying to do is simply replace a background image on a link once the link is clicked. Everything works perfectly in firefox, but i keep getting an error in IE7(go figure).

    I have been working on this for a few hours now and would really appreciate any help you guys can offer.

    The function call is :

    Code:
    		function tooth(jaw,sec,tooth){
    			var obj_t = document.getElementById(jaw + '' + sec + '' + tooth);
    			if(teeth[jaw][sec][tooth] != 1){
    			alert(obj_t.innerHTML);
    				obj_t.style.background="url('images/dot.gif') no-repeat center 4px ;";
    				teeth[jaw][sec][tooth] = 1;
    			}else{
    				obj_t.style.background="transparent;"
    				teeth[jaw][sec][tooth] = 0;
    			}
    		}
    The display/call is:
    Code:
    <a id="u12" title="" href="javascript:tooth('u',1,2)">2</a>
    the function should simply get the link by its ID, check a hash variable to see if it has already been selected and change the background accordingly.

    IE7 gives me an "Invalid property value" on the line
    Code:
    obj_t.style.background="url('images/dot.gif') no-repeat center 4px ;";

    Any help will be greatly appreciated, this has been bothering me for much longer than it should have.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,032
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Try removing the semicolon.
    Code:
    obj_t.style.background="url('images/dot.gif') no-repeat center 4px ;";

  • #3
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow, i can not believe i wasted that much time for it being semicolon.

    Thanks a lot Glenn


  •  

    Posting Permissions

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