http-equiv =“content-language”不起作用(element.lang =“”)

时间:2016-09-10 07:43:33

标签: javascript html http meta

    <html>
    <head>
        <meta http-equiv="content-language" content="es">
    </head>
    <body></body>
    <html>
{
    "responseData": {
        "results": [
            {
                "title": "sobig",
                "titleNoFormatting": "test",
            },
            {
                "title": "test 2 ",
                "titleNoFormatting": "test 2sd",
            },
            {
                "title": "asdasdasda",
                "titleNoFormatting": "asdasdasd",
            },
            {
                "title": "A Warming",
                "titleNoFormatting": "A Warming",
            }

         .
         . 
         . 
         . 
            {
                "title": "last thing",
                "titleNoFormatting": "sada",
            }
        ],

为什么?

According to specification,如果节点或任何节点的祖先(包括根元素)都没有属性集,但有一个pragma-set默认语言集,那么这就是语言节点

1 个答案:

答案 0 :(得分:2)

specification says

  

此功能不符合要求。鼓励作者改为使用lang属性。

Another note说:

  

不应再使用Content-Language元素上http-equiv属性的meta值。

正如What is the HTML5 alternative to the obsolete meta http-equiv=content-language.所示,使用lang=代替:

&#13;
&#13;
console.log("lang = " + document.documentElement.lang);
&#13;
    <html lang="es">
&#13;
&#13;
&#13;

如果你的目标是设定语言,那就更好了。