troubleshooting Question

Javascript causing error on page

Avatar of QuinnDester
QuinnDesterFlag for United Kingdom of Great Britain and Northern Ireland asked on
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

This page shows the error and is calling the function to translate the page.

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

this page is the english version so the javascript function is skipped with an if statment. and shows no error.

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=""></script>
	    <script type="text/javascript">
	    google.load("language", "1");
        function TranslateDiv(divID)
			if ("<%=glbSKIN_COUNTRY_LANG_Code%>" == "EN")
			var test=1;
				var containerDoc = document.getElementById(divID).innerHTML;
				google.language.translate(containerDoc, "en","<%=glbSKIN_COUNTRY_LANG_Code%>" , function(result)
					if (!result.error)
					  var container = document.getElementById(divID);
					  container.innerHTML = result.translation;
    	  <script src="/jsapi?key=internal" type="text/javascript"></script>
		  <script type="text/javascript">
		    google.load('language', "1");
		    function initialize() {
		      var v = {type:'vertical'};

Open in new window


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