Hi, is there a way to measurement system using javascript/JQuery? I need to display some distance and speed values on the page, but It looks like that there is no such function call I can get this information.
views:
61answers:
4No, you can't directly.
You could try this, though: try to get localization information from the http headers or the page (lang attribute etc.). Then you could try something like Microsoft's globalization plugin and see what you come up with.
One work part of the time solution only in JS is to get their Timezone and see if it's US or not. It won't work for say South America or Canada, but it will for most of the world.
You can also grab the user's language to make a guess.
if (navigator.language) { Lang=navigator.language }
else { Lang=navigator.userLanguage }
Or use a service like:
http://gd.geobytes.com/gd?after=-1&variables=GeobytesCountry,GeobytesCity
I know of no way to do that directly. But if you can get the user's preferred locale, you can base it on that. For anything other than en-US, use metric units, and you should be OK. See:
http://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser