Microsoft JScript runtime error: 'content' is undefined..this is the error when i choose languages from the dropdown list. Kindly see the below code of my page.
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Initialize version 1.0 of Google AJAX API
google.load("language", "1");
function translate(lang) {
var source = document.getElementById("article").innerHTML;
var len = content.length;
// Google Language API accepts 500 characters per request
sufyansaeed
Member
15 Points
13 Posts
Re: Website in different language
Jan 13, 2012 01:44 PM|LINK
Dear Kulkarni,
Microsoft JScript runtime error: 'content' is undefined..this is the error when i choose languages from the dropdown list. Kindly see the below code of my page.
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Initialize version 1.0 of Google AJAX API
google.load("language", "1");
function translate(lang) {
var source = document.getElementById("article").innerHTML;
var len = content.length;
// Google Language API accepts 500 characters per request
var words = 500;
// This is for English pages, you can change the
// sourcelang variable for other languages
var sourcelang = "en";
document.getElementById("translation").innerHTML = "";
for (i = 0; i <= (len / words); i++) {
google.language.translate(source.substr(i * words, words),
"en", lang, function (result) {
if (!result.error) {
document.getElementById("translation").innerHTML
= document.getElementById("translation").innerHTML
+ result.translation;
}
});
}
// Hide the text written in the original language
document.getElementById("article").style.display = 'none';
return false;
}
// Switch to the original language
function original() {
document.getElementById("translation").style.display = 'none';
document.getElementById("article").style.display = 'block';
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="translation"></div>
<div id="article">
<h1>
This is heading ...
</h1>
<p>
This is body part which is in paragraph tag.
</p>
<a href="#" onclick="original();">Switch to English</a>
<select onchange="translate(this.options[this.selectedIndex].value);">
<option value="de">deutsch</option>
<option value="pt">português</option>
<option value="fr">français</option>
<option value="ja">日本語</option>
<option value="ar">عَرَبيْ</option>
<option value="it">italiano</option>
<option value="ru">pусский</option>
<option value="po">polski</option>
<option value="zh-CN">中文</option>
<option value="es">español</option>
<option value="ko">한국어</option>
<option value="nl">nederlands</option>
<option value="hi">हिन्दी </option>
<option value="el">Ελληνική</option>
<option value="ro">română</option>
</select>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Thanks for your prompt reply....
Regards
Sufyan