Pre-recorded question

Question #105
How to get page language in JavaScript?
Answer

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 Alphonsio 06/17/2020 at 11:46:15 AM
How to extract page language in JavaScript?
Question by Alphonsio 06/17/2020 at 11:45:54 AM
How to extract page language in JS?
Question by Alphonsio 06/17/2020 at 11:45:30 AM
How to get page language in JS?
Answer by Alphonsio 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 Alphonsio 06/17/2020 at 11:39:57 AM
How to get page language in JavaScript?
# ID Query URL Count

Icons proudly provided by Friconix.