Click to See Complete Forum and Search --> : width of div/layer?


BigBadaBoom
03-31-2003, 07:39 AM
My main question is: How do I find out the width of the div/layer in IE and in NS?

The problem is that the only handle I found with which you can move a layer is:
(IE) document.all.divname.stlye.pixelLeft
(NS) document.layers.layername.left

But I want to line up a div/layer along the right side so if I want the right side to be at pixel 250 I would need to lign the left side up with (250 - width).
I didn't find a way to get hold of the width though :(

Would really appreciate any help!

Ahh - one last small, minor question: Can you make divs/layers semi-transparent? If yes, how?

Thanks a million in advance!
---
BigBadaBoom

khalidali63
03-31-2003, 07:52 AM
Originally posted by BigBadaBoom
.....
(IE) document.all.divname.stlye.pixelLeft
(NS) document.layers.layername.left
---BigBadaBoom

to position a layer at an absolute point,you will need left and top values.
to get these values use document.getElementById("layerID").style.top
document.getElementById("layerID").style.left

for NS6+ and IE6+ browsers.

Cheers

Khalid

BigBadaBoom
03-31-2003, 08:02 AM
Thankyou!

Isn't there another way?
Something that works for 4+ or at least 5+ browsers?

Thanks :)

khalidali63
03-31-2003, 08:04 AM
the above will work for IE 5 as well for ns 4 you have to use the same pattern of code you have for ns4 already.

Khalid

BigBadaBoom
03-31-2003, 08:53 AM
Hmmm....

document.all.MenuIE1.left = 250 - document.getElementById("MenuIE1").style.width;

doesnt seem to work :(

khalidali63
03-31-2003, 08:58 AM
document.all.MenuIE1.left = 250 - document.getElementById("MenuIE1").style.width;

This line should have been coded like this.

obj = document.getElementById("MenuIE1");
obj.left = 250 - obj.left;

And if I am not misteken,you have to explixitly defines left and top values before you can use it this way
e.g
MenuIE1 must already have some values for
top:0;
left:0;

I hope that made some sense.

Khalid

BigBadaBoom
03-31-2003, 09:04 AM
Yes, thankyou!
That is exactly what I needed - it works now! :)

Thanks!