2

Are the list of headers supported by the http-equiv meta tags a limited subset, or does it accept literally anything that you could have as an http header?

Specifically, could I use content-disposition?

Cleric
  • 3,167
  • 3
  • 23
  • 24
haxxerz
  • 893
  • 6
  • 17

1 Answers1

4

Almost all meta tags are ignored by browsers, search engines, and other software.

Even though the HTML 4.01 spec says that “HTTP servers use [the http-equiv] attribute to gather information for HTTP response message headers”, this does not happen. (It happened for a few such attributes very long ago in some special servers.) Instead, meta tags with http-equiv attribute are recognized by browsers, but only in very few cases. The most important case is that http-equiv="Content-Type" may be used to decide on character encoding, if it has been specified in actual HTTP headers.

In HTML5 drafts, meta tags with http-equiv attribute are called “pragma directives”, and an explicit list of allowed values is specified. All the rest are thus non-conforming (and, in practice, mostly write-only tags, ignored by browsers).

You cannot affect anything using content-disposition there. To affect the way a browser deals with, say, a CSV file that you link to in your HTML document, there is probably nothing you can do in HTML. You would have to make the server send actual HTTP headers, typically so that your link refers to a server-side script that fetches the CSV file and sends it along with suitable HTTP headers.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • Hi there... Thanks for the nice explanation! So actually, what I'm trying to do is something slightly different, *the other way around*, in a way. Basically, I have an HTML page rendered already in the browser, of course containing some Javascript. And then I want to do some magic which I haven't quite worked out yet to spark a "save file as..." dialog, from the already loaded javascript. The file I want to get downloaded is itself HTML, and I'd want it to get saved with an HTML extension.... – haxxerz Aug 02 '12 at 07:55
  • But I think the best path I've come up with to explore is `location = 'data:`(some-mime-type)`;`(some-http-header-thingies)`, t

    my html page

    `. I think the ones to explore are `Content-Type` and `Content-Disposition`, and then I think there could be hope in spoofing the MIMEtype to something which the browser knows it can't handle. Like if I make a mimetype of exe chromium can't really do anything with that except for offer the user to dump it into their FS. But then I wonder if I'll be restricted to using a `.exe` filename, y'know?
    – haxxerz Aug 02 '12 at 07:57
  • Any more tips on achieving what I described? – haxxerz Aug 02 '12 at 07:57
  • I don’t quite get what you are trying to achieve, but I think a) it would belong under a different heading, b) it’s probably not possible, for security reasons, c) it’s difficult to imagine when it might be *needed*. Saving an HTML file from a browser is such a simple operation that anyone who could possibly benefit from it can be expected to know how to do it. – Jukka K. Korpela Aug 02 '12 at 10:55
  • @haxxerz Take a look at [this question](http://stackoverflow.com/q/3286423/8655), you should also read up on the [File API](http://www.w3.org/TR/FileAPI/) (though it isn't universally supported yet). – robertc Aug 02 '12 at 11:02