Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-08-2007, 05:24 PM   PM User | #1
gcsjames
New to the CF scene

 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gcsjames is an unknown quantity at this point
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.
gcsjames is offline   Reply With Quote
Old 05-08-2007, 05:39 PM   PM User | #2
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Try removing the semicolon.
Code:
obj_t.style.background="url('images/dot.gif') no-repeat center 4px ;";
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 05-08-2007, 06:39 PM   PM User | #3
gcsjames
New to the CF scene

 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
gcsjames is an unknown quantity at this point
Wow, i can not believe i wasted that much time for it being semicolon.

Thanks a lot Glenn
gcsjames is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:09 PM.


Advertisement
Log in to turn off these ads.