views:

38

answers:

2

I have the following code:

var d = document.createElement("div");
d.id = "d_1";
d.style.backgroundImage = "url(img/lr.png");
d.style.backgroundRepeat = "no-repeat";
d.style.width = "150px";
d.style.height = "25px";
d.style.position = "absolute";
d.style.left = "460px";
d.style.top = "385px";
d.style.visibility = "visible";
document.documentElement.appendChild(d);

and that div isn't show with Opera and Chrome but it's show with firefox!

What's wrong?

+4  A: 

Syntax error.

d.style.backgroundImage = "url(img/lr.png");

Should be

d.style.backgroundImage = "url(img/lr.png)";
nnevala
Yes thanks, but it works only if I set the zIndex attribute!
xdevel2000
Then the problem must be somewhere else and beyond the javascript in your original post.
nnevala
+1  A: 

Correct this line:

d.style.backgroundImage = "url(img/lr.png");

to

d.style.backgroundImage = "url(img/lr.png)";
Silver Light