9

IEによる<base>タグのサポートについてはよくわかりません。一部の記事では、絶対hrefパスでのみ機能することが示唆されています。しかし、それは私にはうまくいきません。

<base href="http://domain.net/qu/en/" />

<a href="sample">Sample Link</a>

ChromeとFFでは、リンクをクリックするとに移動しますhttp://domain.net/qu/en/sampleが、IE9ではに移動しますhttp://domain.net/qu/sample

親戚<base>でも試してみましたが、うまくいかないようです。

私はこれをIE9.08でのみテストしました

4

2 に答える 2

17

IE has always supported <base href>. By the specifications, it has always been defined only when the href value is an absolute URL, though some browsers have had interpreted it even in the case of a relative URL. It must be placed in the <head> part of the document; otherwise browsers may ignore it. The base address can only be set once in a document. (If this is violated, browsers tend to ignore all but the first of them.)

In this case, my guess is that there is some character, outside any tags, before the <base> tag. Consider this:

 <base href="http://domain.net/qu/en/" />
<a href="sample">Sample Link</a>

This is invalid because of the no-break space character before the <base> tag. In HTML parsing, the no-break space, which is not a whitespace character, implicitly closes the <head> element and opens the <body> element. This means that the <base> tag would now be in the <body>. Some browsers may still accept it, but as the document cited in Tieson T’s answer says: “Internet Explorer 7 [and newer] strictly enforces the use of the base tag within the head of the document, and will ignore misplaced tags.”</p>

To check things out, use a validator—it will among other things report problems like this.

于 2012-04-30T07:28:23.213 に答える
1

Microsoftによると、IE 7以降は次のように動作します:http://msdn.microsoft.com/en-us/library/ms535191%28v=vs.85%29.aspx

于 2012-04-30T06:50:59.763 に答える