This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Creating a new img element and cannot change style.left or style.top to set placement as I can in other browsers

  • 3 cavab
  • 1 has this problem
  • 5 views
  • Last reply by Svetlana

more options

I create a new element of type img and am placing in a specific absolute position by setting style.position, style.left and style.top attributes. Works fine in IE and Opera but FF does not allow me to modify any of the style attributes either before or after the element is inserted into the document. I've tested this with 3.5.9 and 3.6.3 and both have the problem.

This happened

Every time Firefox opened

== upon install of FF

I create a new element of type img and am placing in a specific absolute position by setting style.position, style.left and style.top attributes. Works fine in IE and Opera but FF does not allow me to modify any of the style attributes either before or after the element is inserted into the document. I've tested this with 3.5.9 and 3.6.3 and both have the problem. == This happened == Every time Firefox opened == upon install of FF

All Replies (3)

more options

I want to ask for more information. Could you pastebin your code?

more options

Are you including units in your values?

more options

I knew it was something incredibly obvious that I was missing.

by doing

               himg.style.left = (Math.floor(coords[0]) + tweeks.x) + "px";
               himg.style.top = (Math.floor(coords[1]) + tweeks.y) + "px";

instead of

               himg.style.left = Math.floor(coords[0]) + tweeks.x;
               himg.style.top = Math.floor(coords[1]) + tweeks.y;

it works. It seems Opera and IE assume px if nothing supplied while FF needs it explicitly specified.

Thanks!