I'm developing a project in which I need to change the language according to the flag I click using AJAX. It's working fine in IE7 but it shows an error when I run it in IE6.
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script language="javascript">
google.load("language", "1");
function fnTrans(strTransText,strTransField, strTransFLang, strTransTLang)
{
google.language.translate(strTransText, strTransFLang, strTransTLang, function(result) {
var strcontainer = document.getElementById(strTransField);
strcontainer.innerHTML = result.translation ;
});
}
function initialize(strToTxtBox, strFromTxtBox) {
var x = window.location.toString();
var strLang = x.substring(x.indexOf("=")+1);
if((x.indexOf("="))==-1) return;
strFLang = strLang.substring(0,2)
strTLang = strLang.substring(strLang.indexOf("-")+1);
var strText = document.getElementById(strFromTxtBox).innerHTML;
if(strFLang != 'en')
fnTrans(strText,strFromTxtBox, 'en',strFLang)
fnTrans(strText,strToTxtBox, strFLang,strTLang)
}
function fnhi()
{
var label=document.getElementsByTagName("label");
var count=label.length;
var x = window.location.toString();
var strLang = x.substring(x.indexOf("=")+1);
if((x.indexOf("="))==-1)
return;
for(var i=0;i<count;i++)
{
initialize(label[i].id,label[i].id);
}
document.getElementById("curlang").value=strTLang;
}
function fnClick(lang)
{
if(lang=="") return;
var curlang=document.getElementById("curlang").value;
if(lang==curlang) return;
window.location='language.php?strLang=' + curlang+'-'+lang;
}
</script>
</head>
<body onload="fnhi()">
<input type="hidden" id="curlang" value="en" size="3">
<img src= "langauage.gif" use ="#map">
<map name="Map">
<area shape="rect" alt="Arabic" value="ar" coords="36,6,62,19" href="#" onclick="fnClick(this.value);">
<area shape="rect" alt="Chinese" value="zh" coords="66,6,90,20" href="#" onclick="fnClick(this.value);">
<area shape="rect" alt="German" value="de" coords="95,6,121,21" href="#" onclick="fnClick(this.value);">
</map>
</body></html>