Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply absolute position to DOM object for non-IE browsers?

Status
Not open for further replies.

fletchsod

Programmer
Dec 16, 2002
181
I'm trying to apply the "absolute" position to the DOM object for non-IE browsers but Mozilla (or Firefox) does not recognize it. But the top and left position works for the "div" tag though. The IE browser works fine though.

Code:
var iLeft = "580px";
var iTop = "480px";

   //Apply the location (center) to the "div" tag...
   if (document.getBoxObjectFor) {
      //All browsers except Internet Explorer...
      oBusyBoxDivOuter.style.position = "absolute";
      oBusyBoxDivOuter.style.left = iLeft; 
      oBusyBoxDivOuter.style.top = iTop;
   }
   else 
   {
      //Internet Explorer's objects only...
      oBusyBoxDivOuter.style.position = "absolute";
      oBusyBoxDivOuter.style.pixelLeft = iLeft + document.documentElement.scrollTop;
      oBusyBoxDivOuter.style.pixelTop = iTop + document.documentElement.scrollLeft;
   }

Any suggestion or advice on getting absolute position to work for non-IE browsers?

Thanks...
 
Hi

You have a line with something like this, right ? Otherwise oBusyBoxDivOuter would be undefined.
Code:
oBusyBoxDivOuter=document.getElementById('id_of_your_div')

Feherke.
 
Yea, had that getElementById() part. Just didn't added it to the forum post. Oops...

I figure out the problem.

The code should be...

Code:
      //All browsers except Internet Explorer...
      oBusyBoxDivOuter.style.position = "absolute";
      oBusyBoxDivOuter.style.left = String(iLeft) + "px";
      oBusyBoxDivOuter.style.top = String(iTop) + "px";

Seem that I need add the "px" parts to it while IE doesn't seem to need one...

Sorry about that...
 
Hi

Your original code started with this :
Code:
var iLeft = "580px";
var iTop = "480px";
So why to add the 'px' again ?

Anyway, there was nothing wrong with your original code in my FireFox.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top