Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15912

Re: Background image in <TD>

Newsgroups comp.lang.javascript
Date 2012-09-15 17:06 -0700
References <5054ed07$0$6897$e4fe514c@news2.news.xs4all.nl>
Message-ID <183128e4-c5c4-4a73-bab8-fa0afefa5b6b@googlegroups.com> (permalink)
Subject Re: Background image in <TD>
From evlanovsasha@gmail.com

Show all headers | View raw


воскресенье, 16 сентября 2012 г., 1:03:03 UTC+4 пользователь Tom de Neef написал:
> Following html shows the intended behaviour in IE, FF and Chrome: display an 
> 
> image as background to a <TD> element.
> 
> <html>
> 
> <head><title>test</title></head>
> 
> <body>
> 
> <table border="1" cellpadding="2" cellspacing="3">
> 
>   <tr>
> 
>     <td background='expl.bmp'>test</td>
> 
>   </tr>
> 
> </table>
> 
> </body>
> 
> </html>
> 
> 
> 
> I try to achieve this with Javascript but I cannot find the proper way.
> 
>        thisTD.background = "expl.bmp";
> 
> works only with IE.
> 
> I've tried
> 
>        thisTD.style.backgroundImage = "expl.bmp";
> 
> and
> 
>        if (thisTD.style.backgroundImage) {
> 
>          thisTD.style.backgroundImage = "expl.bmp"
> 
>        }
> 
>        else {thisTD.background = "expl.bmp" }
> 
> 
> 
> but none works in FF or Chrome.
> 
> Can you pls do a suggestion. (I don't know what DOCTYPE is used - the html 
> 
> is generated by a server. If that's important: how can I find out?).
> 
> TIA
> 
> Tom

Your code didn't work because you missed: url() and single quote after this.style.backgroundImage =. In this case,  your code should be seems like that:

thisTD.style.backgroundImage = 'url(put_here_path_to_image)';

For more information how is it work you should be read article http://www.w3schools.com/cssref/pr_background-image.asp

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Background image in <TD> "Tom de Neef" <tdeneef@qolor.nl> - 2012-09-15 23:03 +0200
  Re: Background image in <TD> "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-09-15 21:13 +0000
  Re: Background image in <TD> SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-09-16 00:21 +0200
  Re: Background image in <TD> Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-16 01:54 +0200
    Re: Background image in <TD> Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-09-16 11:16 -0600
  Re: Background image in <TD> evlanovsasha@gmail.com - 2012-09-15 17:06 -0700
  Re: Background image in <TD> "Tom de Neef" <tdeneef@qolor.nl> - 2012-09-16 12:48 +0200
    Re: Background image in <TD> "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-16 15:19 +0300
      Re: Background image in <TD> "Tom de Neef" <tdeneef@qolor.nl> - 2012-09-17 09:53 +0200
        Re: Background image in <TD> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-09-17 06:44 -0700
        Re: Background image in <TD> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-09-17 06:46 -0700
        Re: Background image in <TD> Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-17 21:00 +0200
        Re: Background image in <TD> SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-09-18 02:55 +0200

csiph-web