Problems with HTML links in Internet Explorer 8

2019-09-15 13:08发布

问题:

I'm having some problems supporting Internet Explorer 8 in my application.

When a user clicks on a link in non-IE8 browsers, the link works fine and goes to the correct position on the page. Using Internet Explorer 8, however, the links only work when the it doesn't take all of the screen.

To better describe the problem, I took the following screenshots:

DOESN'T WORK

WORKS

Links on the first page appear as such:

<a href="http://domain/sede/ver/4143?tec=fibra#fibra1537"></a>

The IDs for links appear as such:

<a id="fibra1537"></a>

What is happening?

回答1:

I would try to use the name attribute in addition to the id attribute.

<a id="fibra1537" name="fibra1537"></a>

EDIT: @greg explains why here

For HTML documents (and the text/html MIME type), the following processing model must be followed to determine what the indicated part of the document is.

  1. Parse the URL, and let fragid be the <fragment> component of the URL.
  2. If fragid is the empty string, then the indicated part of the document is the top of the document.
  3. If there is an element in the DOM that has an ID exactly equal to fragid, then the first such element in tree order is the indicated part of the document; stop the algorithm here.
  4. If there is an a element in the DOM that has a name attribute whose value is exactly equal to fragid, then the first such element in tree order is the indicated part of the document; stop the algorithm here.
  5. Otherwise, there is no indicated part of the document.