Cloudmersive

Jul 9, 2021

1 min read

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": "https://api.cloudmersive.com/convert/edit/html/head/get/language",
"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 Cloudmersive website; this provides 800 calls/month across any of our APIs.