We help IT Professionals succeed at work.
Get Started

Javascript causing error on page

QuinnDester asked
Last Modified: 2012-05-07
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="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;
				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

Watch Question
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE