troubleshooting Question

Javascript causing error on page

Avatar of QuinnDester
QuinnDesterFlag for United Kingdom of Great Britain and Northern Ireland asked on
JScriptASPHTML
2 Comments2 Solutions281 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
QuinnDester

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros