/    Sign up×
Community /Pin to ProfileBookmark

width of div/layer?

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

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Mar 31.2003 — [i]Originally posted by BigBadaBoom [/i]

[B].....

(IE) document.all.divname.stlye.pixelLeft

(NS) document.layers.layername.left

---BigBadaBoom [/B]
[/QUOTE]


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
Copy linkTweet thisAlerts:
@BigBadaBoomauthorMar 31.2003 — Thankyou!

Isn't there another way?

Something that works for 4+ or at least 5+ browsers?

Thanks ?
Copy linkTweet thisAlerts:
@khalidali63Mar 31.2003 — 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
Copy linkTweet thisAlerts:
@BigBadaBoomauthorMar 31.2003 — Hmmm....

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

doesnt seem to work ?
Copy linkTweet thisAlerts:
@khalidali63Mar 31.2003 — 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
Copy linkTweet thisAlerts:
@BigBadaBoomauthorMar 31.2003 — Yes, thankyou!

That is exactly what I needed - it works now! ?

Thanks!
×

Success!

Help @BigBadaBoom spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...