Question #80   Submitted by Answiki on 06/17/2020 at 11:45:30 AM UTC

How to get page language in JS?

Answer   Submitted by Answiki on 06/17/2020 at 11:45:24 AM UTC

In JavaScript, the best way to get the document language is to use:

document.documentElement.lang;


Another option is to retrieve the <html> tag lang attribute:

document.getElementsByTagName("html")[0].getAttribute("lang");

5 events in history
Question by Answiki 06/17/2020 at 11:46:15 AM
How to extract page language in JavaScript?
Question by Answiki 06/17/2020 at 11:45:54 AM
How to extract page language in JS?
Question by Answiki 06/17/2020 at 11:45:30 AM
How to get page language in JS?
Answer by Answiki on 06/17/2020 at 11:45:24 AM

In JavaScript, the best way to get the document language is to use:

document.documentElement.lang;


Another option is to retrieve the <html> tag lang attribute:

document.getElementsByTagName("html")[0].getAttribute("lang");

Question by Answiki 06/17/2020 at 11:39:57 AM
How to get page language in JavaScript?
# ID Query URL Count

Icons proudly provided by Friconix.