Retrieve the Language Code of an HTML Document in JavaScript

If you’re looking for a simple solution for retrieving the language code of an HTML document, you’re in the right place. In this brief tutorial, we will demonstrate how you can easily automate language code retrieval from an HTML document by using an API in JavaScript.

Let’s get started by running this command to install jQuery:

bower install jquery

With the installation out of the way, we can input the file or file URL to perform the operation on, as well as the API key, into the following code:

var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"inputFileUrl": "<string>",
"Content-Type": "application/x-www-form-urlencoded",
"Apikey": "YOUR-API-KEY-HERE"
},
"data": {
"inputFile": "<binary>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});

In no time at all, the language code will be returned in the results. If you need to obtain an API key, you can do so by register for a free account on the website; this provides 800 calls/month across any of our APIs.

--

--

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.