Hi,

Please see the below html page:

{
<html>
<head> Test Page
<script type="text/javascript" src="http://www.google.com/jsapi";>
</script>
<script src="script.js" type="text/javascript">
</script>
<script type="text/javascript">
google.load("language", "1");
google.setOnLoadCallback(function(result)
{
        alert("Load Completed");
});
</script>
</head>
<body>
<div id="test">
The Input Text is: Hello
<br/>
<button type="submit" onClick="onSubmit();">Submit</button>
</div>
<div id="translation">
</div>
</body>
</html>
}


Below is the JavaScript File:

{
function onSubmit()
{
        alert("on Submit");
        google.language.translate("hello", "en" , "es", function(result)
        {
        alert("in handle result");
        if (!result.error)
        {
                var translated = document.getElementById("translation");
                translated.innerHTML = "<p>The translated text is:</p><br/
>"+result.translation;
        }
        });
}
}

The above works perfectly fine. However, I dont want to perform the
load separately in the html file. I want to put all js code in the
separate script file and hence calls to "google.load()" api also I
want to invoke from external file.

In the above if I make the following changes:

{
<script type="text/javascript">
function onStartup()
{
google.load("language", "1");
google.setOnLoadCallback(function(result)
{
        alert("Load Completed");
});
}
</script>

and make the following change:

<body onload="onStartup();">

}

The page will not work.

My Question is Is there an alternate way to Load the js language api
externally? If not can it be provided in the near future?

Thanks and regards,
Bobby
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to