I have a alert message,
alert('Hi')
it prints, Hi
in the alert window.
I want that message Hola
to be printed when someone whose IE is set to Spanish.
How can I go about doing that please?
Thank you
I have a alert message,
alert('Hi')
it prints, Hi
in the alert window.
I want that message Hola
to be printed when someone whose IE is set to Spanish.
How can I go about doing that please?
Thank you
Check this:
<script type="text/javascript">
window.onload = function() {
var language = window.navigator.userLanguage || window.navigator.language;
alert(language); //works IE/SAFARI/CHROME/FF
}
</script>
Once you have detected language you can have a case to switch the alert message.
This should work in most browsers:
var languageinfo = navigator.language ? navigator.language : navigator.userLanguage;
if(languageinfo.split('-')[0] == 'es') {
alert('hola')
} else {
alert('hi');
}