473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

IE7: offsetLeft

Frinavale
9,735 Expert Mod 8TB
IE7 has a bug regarding the offsetLeft.
It always returns 0 even if the element is not at left:0.

Well to be fair the element is at left:0 with respect to it's parent element...but the element is not actually at left:0 because some parent (or grand parent...) element has a style that positions the element away from the left side of the page.

**sigh**

This has made a mess, once again, of my JavaScript and my server control code too because I had to add code that exposes the ID of the parent/grandparent element that is being directly effected by the positioning move.

This bug does not exist in IE8... nice of them to fix it...but at the same time the fix is useless to me since I have to support 7.

Anyways, what I'm trying to do is pretty straightforward.

I want to display a <div> with a position:absolute style over top of the content that is being processed so that the user doesn't try to do something with data that is being worked on.

The thing is that the <div> that is displayed over top of the content is within another <div> that has a position:absolute style. This is so that the parent div can cover up the ASP.NET control that the the "blocker" control is "attached to".

I recently found a case where I wanted to use 1 of these blockers for more than one ASP.NET control....so that means it's not "attached to" anything.

Originally I had the control cover the entire page but decided that the buttons at the top (that let the user access help or logout) shouldn't be covered....and neither should the page's logo section at the top of the page.

So I just wanted to cover the "content" section of the page. This seemed easy enough because the page's content is within a <div> and I know the ID of the div...all I had to do was move the <div> that blocked the content over top of the main "content" section and expand it's width and height to match it.

Easy enough except the fact that the parent <div> of the blocker <div> has the position:absolute style....fine I can get a reference to the this div to.

So I decided to move the parent <div> so that is over top of the main content section of the page.

This is where the offsetLeft property is really messing me up...

Even if I retrieve the main "content" section's offsetLeft property it's Not Right...and I don't know why.

I removed all padding and margin styles from the content section and it's still off by (I don't know) 10 or so pixels.

Anyone have any ideas on why the offsetLeft property in IE7 is always wrong...and how I can get around the problem?

-Frinny
Mar 30 '10 #1

✓ answered by gits

you might have a look here ... probably section 2.2 ...

kind regards

4 4261
gits
5,390 Expert Mod 4TB
you might have a look here ... probably section 2.2 ...

kind regards
Mar 30 '10 #2
Frinavale
9,735 Expert Mod 8TB
Thanks Gits!

I didn't come across this article when I was looking for answers.
I don't really want to check for browser version (I've managed to implement scripts that aren't dependent on browser versions so far) but in this case I might just have to.

It's actually section 2.1 that applies to my particular problem.

-Frinny
Mar 31 '10 #3
Frinavale
9,735 Expert Mod 8TB
This got a bit too buggy so I gave up and decided not to cover just the content portion of the page.

If the blocker isn't attached to a particular control it blocks the whole page instead of just the portion that I wanted to block.

Thanks a lot for your help.

-Frinny
Mar 31 '10 #4
gits
5,390 Expert Mod 4TB
as always crappy IE is causing problems :) ... basicly to handle all such cross-browser issues for yourself will lead to a quite big portion of code ... once you start with it then you probably will create an open ended issue list ... i mean: solved this issue, so why not the next one and so on. if you could find a quite lightweight lib which covers the problem i would suggest to use that ... or do what you did: just avoid a feature that causes such issues :)

kind regards,
gits
Mar 31 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pieter Van Waeyenberge | last post by:
Hello In the code below, theres a DIV, a TABLE and another DIV , each with an image in it. When i read out the offsetLeft/Top from imgB in the table , i get offset values relative to the...
11
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below...
4
by: Keith Thornhill | last post by:
I'm trying to calculate the top and left distance from the side of the browser of an object (either absolutely or relatively positioned) and i'm running into a weird problem as i'm trying to make...
3
by: ara.pehlivanian | last post by:
I've got a script that determines the true position of an element in the page by cycling up the .offsetParent elements all the way up to the <body> element and tallying up the .offsetLeft values...
10
by: Matt Kruse | last post by:
See: http://www.mattkruse.com/temp/offsetleft.html It appears that the offsetLeft value in IE6 (other versions not tested) incorrectly ignores the border width on a DIV when there is a width:...
2
by: Gary Coutts | last post by:
Hi, I am developing a website using Visual Studio .Net 2003. When reading offsetLeft, in a javascript function, the result is fine when run under I.E. but gives wrong results when run under...
2
by: rohitchawla | last post by:
have a problem with this code when working in IE it gives me 0,0 coords when i use iframe tag but gives correct coords when using firefox function GetRealOffset(id) { var elem =...
4
by: RaymondXie | last post by:
Hi folks, This is my first post. I have an app working perfectly under IE6 but failing in IE7 or FireFox. I believe something wrong with the CSS. I've attached my code below. The whole idea is...
3
by: Nitinkcv | last post by:
Hi all, Im trying to do the following: Have 3 divs which are placed side by side. each has a two links 'left' and 'right'. Say on click of the 'left' hyperlink of the 2nd div(middle), the 1st...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.