Can I get the operating system measurement system (metric or american) in javascript

Is there a way to measure the system using javascript / jQuery? I need to display some distance and speed values ​​on the page, but it looks like there is no such function call. I can get this information.

+3
source share
3 answers

No, you cannot directly.

You could try this: try to get localization information from http headers or a page (attribute lang, etc.). Then you can try something like a Microsoft globalization plugin and see what you come up with.

+1
source

, . , . , en-US, , . :

+1

One working part of the workaround only in JS is to get their time zone and see if it is US or not. This will not work, for example, in South America or Canada, but it will be for most of the world.

You can also capture the user's language to make an assumption.

if (navigator.language) { Lang=navigator.language } else { Lang=navigator.userLanguage }

Or use a service, for example:

http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity

0
source

Source: https://habr.com/ru/post/1749989/


All Articles