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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Table Cell Image Background (help please)

    Hi people I have put an image as a baground for a table cell but the image is tiled and I want it to strech heres the code for what I have done so far:
    Code:
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="349" height="150">
        <tr>
          <td width="349" height="150" background="image.gif">
          </td>
        </tr>
      </table>
    Can anyone please help me?
    Thanks to anyone that helps.
    Last edited by MichaelBowler; 07-15-2004 at 04:19 PM.

  • #2
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK then people just ignore me

  • #3
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You cannot do this with a TD background. Since you put this question in a Javascript forum, I'll show you a Javascript example There isn't a method for assigning sizes to an image that is going to be used as a background image. You'll notice I even created an image in Javascript that has the sizes defined and it is ignored by the TD and DIV.

    http://staging.paragraphinc.com/imageBGtest.htm

    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	// Set the Image tag source
    	theIMG.src = theImage.src;
    	// Set the TD bg image
    	theTD.style.backgroundImage = "url(" + theImage.src + ")";
    	// Set the DIV bg image
    	theDIV.style.backgroundImage = "url(" + theImage.src + ")";
    }
    </script>

  • #4
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Patience, Grasshopper.

    You weren't ignored... you didn't post this in the correct forum.

  • #5
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK then I apologise to everyone that was offended by my second post in this thread.

  • #6
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you explain this script in more detail? Please...
    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	theIMG.src = theImage.src;
    	theTD.style.backgroundImage = "url(" + theImage.src + ")";
    	theDIV.style.backgroundImage = "url(" + theImage.src + ")";
    }
    </script>
    And does theTD in this part of code refer to an ID or Class?
    Code:
    theTD.backgroundImage = "url(" + theImage.src + ")";
    And thanks again to anyone that does help...
    And how do you apply this script to a TD?
    Last edited by MichaelBowler; 07-15-2004 at 05:45 PM.

  • #7
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Number_Nineteen

    Your script isn't working for me ...
    l'll post the code in a minute.

  • #8
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	// Set the Image tag source
    	theIMG.src = theImage.src;
    	// Set the TD bg image
    	theTD.style.backgroundImage = "url(" + theImage.src + ")";
    	// Set the DIV bg image
    	theDIV.style.backgroundImage = "url(" + theImage.src + ")";
    }
    </script>
    Maybe it isnt working because of the line in green? I see no variable by the name of theIMG, but i do see one by the name of theImage.
    LovesWar

  • #9
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So how would you sort that then?

  • #10
    Regular Coder
    Join Date
    Jul 2004
    Location
    engoku no anime
    Posts
    354
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Um... Try this:

    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	theIMG.src = theImage.src;
            theTD.style.backgroundImage = "url(theImage.src)";
            theDIV.style.backgroundImage = "url(theImage.src)";
    }
    </script>
    or:

    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	var theIMG = theImage.src;
    	theTD.style.backgroundImage = "url(theIMG)";
            theDIV.style.backgroundImage = "url(theIMG)";
    }
    </script>

  • #11
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Funny, but for IE, you do need to specifically say var inorder for IE to understand that something is a variable, as opposed to a value. I've noticed that some times it will give me object undefined, whenever i created a variable without the key word. It's annoying.
    LovesWar

  • #12
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I've noticed that some times it will give me object undefined, whenever i created a variable without the key word. It's annoying.
    I don't think so. You might have had another type of mistakes, such as choosing reserved words as variable names or giving the same name for a variable and for an object's name or id.

    In fact variables can be

    1. local
    var blah = ...
    2. global
    blah = ...

    So this is the 'mistery' for using somethimes with sometimes without var specification
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #13
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by gohankid77
    Um... Try this:

    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	theIMG.src = theImage.src;
            theTD.style.backgroundImage = "url(theImage.src)";
            theDIV.style.backgroundImage = "url(theImage.src)";
    }
    </script>
    or:

    Code:
    <script language="JavaScript">
    function loadImage() {
    	var theImage = new Image(150,349);
    	theImage.src = "http://www.google.com/images/logo.gif";
    	var theIMG = theImage.src;
    	theTD.style.backgroundImage = "url(theIMG)";
            theDIV.style.backgroundImage = "url(theIMG)";
    }
    </script>
    Sorry its still not working

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Quote Originally Posted by MichaelBowler
    Hi people I have put an image as a baground for a table cell but the image is tiled and I want it to strech heres the code for what I have done so far:
    Code:
      <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="349" height="150">
        <tr>
          <td width="349" height="150" background="image.gif">
          </td>
        </tr>
      </table>
    Can anyone please help me?
    Thanks to anyone that helps.
    AFAIK, you can't stretch a backgound image. You can only make it not tiled and position it somewhere.

    <table border="1" width="100%">
    <tr>
    <td style="background:url(image.gif) no-repeat center">The backgound image is in the center of this cell</td>
    </tr>
    </table>

  • #15
    New Coder
    Join Date
    Jun 2004
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    AFAIK, you can't stretch a backgound image. You can only make it not tiled and position it somewhere.

    <table border="1" width="100%">
    <tr>
    <td style="background:url(image.gif) no-repeat center">The backgound image is in the center of this cell</td>
    </tr>
    </table>
    Not working Glenn mate
    Maybe my Internet Explorer is sh*t.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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