how to obtain offsetLeft

L

lcplben

Hi everyone --

Page that shows the problem is at:

www.sellmycalls.com/offset-left.html

I need to see the offsetLeft of the div id="main" but no matter what I
try, I can't retrieve that thing.

What am I doing wrong or, better, what can I do right to see that
datum?

Thanks so much!

-- ben
 
L

lcplben

What exactly is the problem? The "main" div's offsetLeft value is zero,
which is exactly what your "debug" div shows. At least that's what I can
see after a quick check with Firefox. Do you have a problem with other
browsers?

By the way, I'd get rid of that getRefToDiv function - just replace it
with document.getElementById. And I'm curious, what's the intention for
this line?

  <meta content="http://www.sellmycalls.com" http-equiv="Location"/>

cheers,
stefan

I should have said before: if I scroll the content left, offsetLeft
stays at zero. Of course, I want offsetLeft to reflect the scroll
state of the div.

That line, in the production version of the page (not this tinified
example), gives the user's browser a 301 header to send the user to
that named page. I actually don't think this meta header works;
instead, I put out this http header from my cgi.

Thanks!

-- ben
 
R

rf

lcplben said:
I should have said before: if I scroll the content left, offsetLeft
stays at zero.

Of course it does. The div is still at the left hand side of the page.
Of course, I want offsetLeft to reflect the scroll
state of the div.

Are you perhaps thinking that offsetLeft refers to the viewport? It's the
viewport being "scrolled", not the content, or the div.
 
L

lcplben

Of course it does. The div is still at the left hand side of the page.


Are you perhaps thinking that offsetLeft refers to the viewport? It's the
viewport being "scrolled", not the content, or the div.

I /was/ thinking that, yes, thanks. So how do I find out how many
pixels are hidden behind the left edge of the viewport when I scroll
the viewport to the right?

Thanks!

-- ben
 
L

lcplben

I /was/ thinking that, yes, thanks. So how do I find out how many
pixels are hidden behind the left edge of the viewport when I scroll
the viewport to the right?

Thanks!

-- ben

I've tried scrollLeft in the scrolling test code at the bottm of:

http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

and that code always returns x = 0 for scrollLeft; and y = scrollTop
in FF 3.5.3, IE 7.0, and Safari 4.0 so I'm completely puzzled.

-- ben
 
L

lcplben

Of course it does. The div is still at the left hand side of the page.


Are you perhaps thinking that offsetLeft refers to the viewport? It's the
viewport being "scrolled", not the content, or the div.

Yes, I was thinking that. Thanks, rf. It's working just fine now.

-- ben
 
T

Thomas 'PointedEars' Lahn

lcplben said:
What exactly is the problem? The "main" div's offsetLeft value is zero,
which is exactly what your "debug" div shows. At least that's what I can
see after a quick check with Firefox. Do you have a problem with other
browsers?

By the way, I'd get rid of that getRefToDiv function - just replace it
with document.getElementById. And I'm curious, what's the intention for
this line?

<meta content="http://www.sellmycalls.com" http-equiv="Location"/>
[...]

I should have said before: if I scroll the content left, offsetLeft
stays at zero. Of course, I want offsetLeft to reflect the scroll
state of the div.

So scrollLeft instead. RTFM.
That line, in the production version of the page (not this tinified
example), gives the user's browser a 301 header to send the user to
that named page. I actually don't think this meta header works;

Because it is not a header at all.
instead, I put out this http header from my cgi.

Don't. And trim your quotes.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top