/ Published in: jQuery
                    
                                        
this snippet allows you to receive the browser default language (IE & other).
- change content based on the lang
- German
- Russian
- English
- Japanese
- and default
have fun http://itreptil.at
                - change content based on the lang
- German
- Russian
- English
- Japanese
- and default
have fun http://itreptil.at
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
(function($){
//
// DIV must be style="display:none;"
//
$.fn.chk_userlanguage = function() {
/* check if <style=display:none;> not set to that element */
if (!this.is(":hidden")) { this.hide(); };
/* get browser default lang */
if (navigator.userLanguage) {
baseLang = navigator.userLanguage.substring(0,2).toLowerCase();
} else {
baseLang = navigator.language.substring(0,2).toLowerCase();
}
/* language match */
switch(baseLang)
{
case "de":
/* german */
this.slideDown("slow");
break;
case "en":
/* english */
break;
case "ja":
/* japanese */
break;
case "ru":
/* russian */
break;
default:
/* default no match */
}
};
})(jQuery);
Comments
 Subscribe to comments
                    Subscribe to comments
                
                