473,698 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot Insert Preloaded Background Image into TR, TD in IE

why am i unable to insert image background into a tr or td element in
IE using preloaded image object, like this:

var img = new Image();
img.src = 'blah.gif';
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";

<table><tr id='someId'><td >content</td></tr></table>

May 8 '07 #1
3 6500
wrote on 08 mei 2007 in comp.lang.javas cript:
why am i unable to insert image background into a tr or td element in
IE using preloaded image object, like this:

var img = new Image();
img.src = 'blah.gif';
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";

<table><tr id='someId'><td >content</td></tr></table>

Works fine over here in IE7.
The id-ed element must be ready, of course.

<table><tr id='someId'>
<td>content<br> <br><br><br><br ><br><br><br>
</td></tr></table>

<script type='text/javascript'>
var img = new Image();
img.src = 'blah.gif';
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 8 '07 #2
ASM
vu******@gmail. com a écrit :
why am i unable to insert image background into a tr or td element in
IE using preloaded image object, like this:

var img = new Image();
img.src = 'blah.gif';
is the document completly loaded when you do the following ?
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";
onload = function() {
var d = document.getEle mentById('someI d').style
d.backgroundIma ge = 'url('+img.src+ ')';
}

works with my FF, IE(mac), Safari and some others
<table><tr id='someId'><td >content</td></tr></table>


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
May 8 '07 #3
On May 8, 9:57 am, "Evertjan." <exjxw.hannivo. ..@interxnl.net wrote:
wrote on 08 mei 2007 in comp.lang.javas cript:
why am i unable to insert image background into a tr or td element in
IE using preloaded image object, like this:
var img = new Image();
img.src = 'blah.gif';
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";
<table><tr id='someId'><td >content</td></tr></table>

Works fine over here in IE7.
The id-ed element must be ready, of course.

<table><tr id='someId'>
<td>content<br> <br><br><br><br ><br><br><br>
</td></tr></table>

<script type='text/javascript'>
var img = new Image();
img.src = 'blah.gif';
document.getEle mentById('someI d').style.backg roundImage =
"url('"+img.src +"')";
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
thank you for inspiration! i just did something wrong...

May 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3953
by: Display Name | last post by:
I can't insert an image using the "add a new stylesheet" function- the function, on dreamweaver MX (i'm on Windows 2k Pro) seems to work as it generates the code... but the image never shows up in the background. I've tried it on multiple HTML pages. I've even tried taking the BG image out and seeing if just setting a black BG color works - it doesn't. If I add in the BACKGROUND="" to the BODY tag manually, it works fine. Everything...
2
7562
by: Thomas Mlynarczyk | last post by:
Hi! When I assign a different background image "on hover" for an element, such as a {background-image:url(normal.gif);} a:hover {background-image:url(hover.gif);} is the hover image then automatically preloaded by the browser? Or would I have to include a JavaScript preload to make sure? (Mozilla seems to
7
10441
by: John A. | last post by:
Hello all! I've got a big bunch of pages using tables for layout. Eventually I'll get them set up with more modernized code, but in the meantime I'd like to slip in a little quick holiday decoration. I'd like to insert a table cell with a fixed width (as much as such things can be fixed) and a repeating garland background so as to show up along the left side of the table, repeating down its length. Our site has a couple thousand...
13
3963
by: Giggle Girl | last post by:
Hi there, I need to use a background image in a TR that does NOT restart everytime it hits a TD. Can it be done? Specifically, if you set a background image for an entier table, now mater how many TRs and TDs you have, it will show the complete/unfragmented image (as long as you don't over-ride it). When I set a TR background image, every time I hit a TD it "re-seeds" the image. I want to have a TR that shows an 800px image in it's
6
2357
by: MLH | last post by:
I have a logo image that I can paste into MS Paint as an image with clear background. Think of the logo as a black circle in a white, rectangular background. When I paste into Paint, the white back- ground can be made "clear" so it does NOT overwrite other image data when I'm pasting into an existing picture. Just the circle would appear after the paste is made. However, when I try to accomplish the same thing with an Access 97 form,...
3
3236
by: Viken Karaguesian | last post by:
Hello all, I need somehelp with background tiling. I have a sneaking suspicion that what I want to do is not possible, but I'll ask anyway. :>) First some background: Here's the site in question: www.sayatnova.com (I'm sure many of you have seen this before as I've often asked for help). I've come a long way since I first created the site many moons ago and I'm trying to convert it to a (1) Table-less, (2) Frame-less and (3) Validated...
62
17788
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image(); img.src = ; Then I use the image a few more times by adding it into an Array object:
6
7231
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an attribute (HTML or CSS) that is making use of a URL to display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image, image maps, css assigned background, etc. Honestly, I am probably not aware of all the possibilities...
2
14071
by: thephatp | last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE. I have created a sample page, and I'm really confused as to what is going on in IE. FF renders the page exactly as I expect. IE renders the page with everything in the correct location, but it seems to double the background image for a sub-div section that is moved up using a negative...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9027
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2329
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.