Solved

FireFox - Onclick Set Table Cell Background Image..

Posted on 2006-11-02
3
780 Views
Last Modified: 2008-02-01
Below Javascript function works (toggle background image) great in IE but NOT in FireFox.

 function CircleTD(id){
       if (document.getElementById('Hid2').value!="185")
        {
            if(id.background=="")
        id.background="../Images/CircleTD1.bmp";
            else
                  id.background="";
        }
    }
...Table cell
<TD id="tdC" onclick="CircleTD(tdC)" align="center" width="3.8%">C</TD>

Apparently, found that 'background' property is an MS extension for HTML Object. I tried to apply style sheet background property, it seem to work with in-line style property but not when onclick with javascript. I would like to make this work on both IE and FireFox, any workable alternatives would be greatly appreciated. Thank you!
0
Comment
Question by:rcsunkara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:yeroket
ID: 17866189
try
document.getElementById("tdC").style.background=...
0
 

Author Comment

by:rcsunkara
ID: 17868643
Hi Yeroket,

Thank you for the response. I tried that it didn't work but the below CSS style sheet classes to set background image seem to work on both IE and FireFox.

.tdImage
{
  background-image:  url(Circle.bmp);
}
.tdUnImage
{
  background-image: url(EmptyCircle.bmp);
}

function mouseIn(cell)      {     
      if(cell.className=='tdImage'){
            cell.className='tdUnImage';
       }
       else {
            cell.className='tdImage';
       }
}
I am closing this issue.
0
 
LVL 15

Accepted Solution

by:
JakobA earned 500 total points
ID: 17871355
The standard name for the background image attribute is background-image (in CSS) or backgroundImage (using JavaScript)
eg:
<SPAN
    onmouseover="this.style.backgroundImage='url(yourpic.jpeg)'"
    onmouseout="this.style.backgroundImage='url(none)'"
>content of the span</span>
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question