Mark Vickery
Mark Vickery

Reputation: 1955

IE6 & 7, JavaScript "Member not found" bug

I've written some JavaScript that embeds an image into a page.

The end result is successful on all browsers (even IE6 & 7) but with IE6 & 7 I get the message "Line 15, Character 5, Member not found". Here is the code:

09: var url = getUrl();
10: url += 'Impression';
11: url += '?' + getParams();

12: var img = new Image();
13: img.src = url;
14: img.style = "display = 'none';";
15: document.body.insertBefore(img, document.body.firstChild);

Are either document.body.insertBefore or document.body.firstChild not fully supported in IE6 or 7?

Upvotes: 1

Views: 659

Answers (1)

Rob W
Rob W

Reputation: 349232

IE throws errors for invalid CSS property assignment. In this case, img.style = "display = 'none';"; is invalid.

It should be either of these:

  • img.style.display = 'none';
  • img.style.cssText = "display:none;";

Upvotes: 5

Related Questions