Link to home
Start Free TrialLog in
Avatar of QuinnDester
QuinnDesterFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Javascript causing error on page

I have added google translate to my web site, its all working great but i have the yellow triangle saying there is an error on the page.

I have narrowed the cause down to the javascript that calls the translation api.

there is no error when the if statment (see code below) is met and the javascript function is skipped ie when on the english site, but whe the if statment is not met the error apears, even when there is no code in the page to call the function

example
This page shows the error and is calling the function to translate the page.
http://sv.testskin.co.uk/category/PMR-Acess/10428/product/Covert-Earpiece_Boom-Microphone-Covert-boom-mic-mot-/3144999.htm

this page shows the error but isnt calling the function at all.

http://sv.testskin.co.uk/page/faqs.htm

this page is the english version so the javascript function is skipped with an if statment. and shows no error.
http://www.testskin.co.uk/

Can sombody have a look at the code below and see if you can see an error please.

also the test var is only in the code so the first part if the if stament is not empty... i couldnt get
if (!"<%=glbSKIN_COUNTRY_LANG_Code%>" == "EN") to work so had to go with true and put the code in the else statment.

there are scripts here one does the translation the other displays the google logo, they work indipendantly, i have tried removing the credit display script but this had no effect on the error.
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
	    <script type="text/javascript">
 
	    google.load("language", "1");
 
 
 
        function TranslateDiv(divID)
        {
 
			if ("<%=glbSKIN_COUNTRY_LANG_Code%>" == "EN")
			{
			var test=1;
			}
			else
			{
				var containerDoc = document.getElementById(divID).innerHTML;
 
 
				containerDoc=containerDoc.toLowerCase();
				google.language.translate(containerDoc, "en","<%=glbSKIN_COUNTRY_LANG_Code%>" , function(result)
				{
					if (!result.error)
					{
 
					  var container = document.getElementById(divID);
					  container.innerHTML = result.translation;
					}
				 });
			 }
	     }
 
 
    </script>
    	  <script src="/jsapi?key=internal" type="text/javascript"></script>
 
		  <script type="text/javascript">
 
		    google.load('language', "1");
		    google.setOnLoadCallback(initialize);
		    function initialize() {
		      var v = {type:'vertical'};
 
		      google.language.getBranding('google');
 
		    }
 
	  </script>

Open in new window

SOLUTION
Avatar of Jonah11
Jonah11

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial