steve_d555
September 5th, 2005, 12:50 AM
As you all should know, XHTML should be sent as application/xhtml+xml
Sadly, Internet Explorer is not smart enough to be able to parse it and insteads starts downloading as a file. There is a way around this, by changing Content-Types you will still be able to validate as proper XHTML (1.1 in my case), but allow IE users to see your website.
Just put the following in your controller and call it whenever needed. There is a special case for the W3C Validator as it does not send out that it accepts application/xhtml+xml.
def set_header()
http_accept = @request.env["HTTP_ACCEPT"]
if @request.env["HTTP_USER_AGENT"].scan("W3C_Validator") != nil
@headers ["Content-Type"] = "application/xhtml+xml"
else
if http_accept.scan("application/xhtml+xml") != nil
@headers["Content-Type"] = "application/xhtml+xml"
elsif http_accept.scan("application/xml") != nil
@headers["Content-Type"] = "application/xml"
elsif http_accept.scan("text/xml") != nil
@headers["Content-Type"] = "text/xml"
else
@headers["Content-Type"] = "text/html"
end
end
end
Hope this helps some people.
Sadly, Internet Explorer is not smart enough to be able to parse it and insteads starts downloading as a file. There is a way around this, by changing Content-Types you will still be able to validate as proper XHTML (1.1 in my case), but allow IE users to see your website.
Just put the following in your controller and call it whenever needed. There is a special case for the W3C Validator as it does not send out that it accepts application/xhtml+xml.
def set_header()
http_accept = @request.env["HTTP_ACCEPT"]
if @request.env["HTTP_USER_AGENT"].scan("W3C_Validator") != nil
@headers ["Content-Type"] = "application/xhtml+xml"
else
if http_accept.scan("application/xhtml+xml") != nil
@headers["Content-Type"] = "application/xhtml+xml"
elsif http_accept.scan("application/xml") != nil
@headers["Content-Type"] = "application/xml"
elsif http_accept.scan("text/xml") != nil
@headers["Content-Type"] = "text/xml"
else
@headers["Content-Type"] = "text/html"
end
end
end
Hope this helps some people.