Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagemap AREA tags' offsetLeft and offsetTop are not defined in the HTML spec #5

Open
bitcrazed opened this issue Oct 24, 2011 · 1 comment

Comments

@bitcrazed
Copy link

Problem: Imagemap AREA tags' offsetLeft and offsetTop are not defined in the HTML spec which has led to different browsers exhibiting different behaviors.

Consider an HTML ImageMap with a couple of AREA’s:

    <img alt="Image" src="./TestImage.jpg" usemap="#myMap" />
    <map name="myMap" id="myMap">
        <area id="Fox" alt="Fox" shape="rect" coords="344,0,530,170" />
        <area id="Grass" alt="Grass" shape="rect" coords="80,160,250,280" />
    </map>

Using jQuery/javascript, attach mouseover events to the AREA tags. In the event handler, examine the AREA tag’s offset left & top parameters.

IE exhibits what I believe to be the correct behavior, but both Firefox and Chrome exhibit incorrect, and different behaviors:

  • IE9 reports the offsetLeft and offsetTop correctly
  • Firefox returns the offsetLeft and offsetTop of the image itself.
  • WebKit/Chrome return 0 for both offsetLeft and offsetTop!

This bug prevents reliably determination of the bounding box surrounding an AREA using the offsetLeft and offsetTop parameters. Because of the inconsistent browser behaviors, To work around this, developers have to write code to calculate the bounding box from the cords list for rect and poly area types and also for circle area types.

I’ve filed bugs against Firefox (here) and Chrome (here) for this issue.

I had originally discovered this issue when using the jQuery .position() method which fails because of the above difference in behavior. Please consider driving a common understanding of the offsetTop and offsetLeft properties of AREA tags through the W3C HTML spec process.

@leobalter
Copy link
Collaborator

The bugs are still open, the Firefox got marked as duplicate of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants