0

So I've got a an HTML5 website setup and I've been programming a for of language toggle

The site always starts like this...

<!DOCTYPE html>
<!--[if IE 7]><html lang="fr" class="no-js ie7"><![endif]-->
<!--[if IE 8]><html lang="fr" class="no-js ie8"><![endif]-->
<!--[if gt IE 8]><!-->
<html lang="fr" class="no-js">

I'm building a language detection script and I'm trying to cache

<html lang="fr" class="no-js">

Or more specifically the "fr" and "en" into a variable upon the activation of my script...

How would I go about fetching the language declaration into a variable?

1
  • Edited your title. JScript was the MS implementation of JavaScript. Commented Nov 27, 2012 at 21:50

1 Answer 1

2
var lang = document.documentElement.getAttribute("lang");

or just

var lang = document.documentElement.lang;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.