為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

What standard, if any, specifies how a browser responds to a content type specified by the "type" attribute of the anchor tag?

more options

I had hoped that the following HTML code would FORCE the browser responding to the anchor by treating the content as plain text: <a href="file:path" type="text/plain">anchor text</a>. Likewise: <a href="file:path" type="text/html">...</a> should FORCE the browser to treat the responding reference as HTML code. Firefox does this (good for you!). However, Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension). I was hoping to find a standard that describes how a browser handles a source-specified content type. I have looked at W3C's html and http standards and have yet to find any applicable description or requirement. Obviously I am looking for some way to code the source file so that when anchors are followed, they are displayed as I want them to be. I can not change the destination file content (or name) -- that is already determined by its own needs.

I had hoped that the following HTML code would FORCE the browser responding to the anchor by treating the content as plain text: <a href="file:path" type="text/plain">anchor text</a>. Likewise: <a href="file:path" type="text/html">...</a> should FORCE the browser to treat the responding reference as HTML code. Firefox does this (good for you!). However, Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension). I was hoping to find a standard that describes how a browser handles a source-specified content type. I have looked at W3C's html and http standards and have yet to find any applicable description or requirement. Obviously I am looking for some way to code the source file so that when anchors are followed, they are displayed as I want them to be. I can not change the destination file content (or name) -- that is already determined by its own needs.

被選擇的解決方法

Hi asicchecker, regarding what is "required", did you follow Gingerbread Man's links?

These are more direct:

HTML 4.01: http://www.w3.org/TR/html401/struct/links.html#h-12.2

HTML5: http://www.w3.org/TR/html5/links.html#attr-hyperlink-type (same)

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-type

從原來的回覆中察看解決方案 👍 1

所有回覆 (5)

more options

asicchecker wrote:

Google Chrome and Internet Explorer seem to ignore the given content type and treat the response according to however they feel (which seems to be according to the file extension).

Is your server not sending a Content-Type header? Does the document lack a meta content-type tag? Either of those could take precedence over the link's type attribute.

asicchecker wrote:

I have looked at W3C's html and http standards and have yet to find any applicable description or requirement.
more options

My Server is my browser (which I would also claim is my Client). When using a File scheme of the URI, the file requester (the browser when I click on an anchor) has no other http entity to from which to request the file. The browser gets the file locally from the operating system, and "returns" the file to itself. The same browser then renders the returned file according to some rule (including content type).

Perhaps the browser is supposed to send a Content-Type header to its own child process. If so, how could I tell?

more options

With a local file, there is no server response header to tell the browser what content-type the file is, so the browser has to use the extension name for that.

more options

Clearly, the browser does not "have to" use the extension. Firefox does not. Since Firefox (and any other browser) already "knows" that the anchor has been given a content-type, it can use that given type -- although some other browsers choose not to. Further, my question is whether or not this is required by some HTTP/HTML/Browser/URI/MIME standard (and if so, where).

more options

選擇的解決方法

Hi asicchecker, regarding what is "required", did you follow Gingerbread Man's links?

These are more direct:

HTML 4.01: http://www.w3.org/TR/html401/struct/links.html#h-12.2

HTML5: http://www.w3.org/TR/html5/links.html#attr-hyperlink-type (same)

MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-type