Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/05/2010, 00:46
Curda
 
Fecha de Ingreso: septiembre-2009
Ubicación: Queretaro
Mensajes: 51
Antigüedad: 14 años, 7 meses
Puntos: 2
Exclamación Ayuda con un script

Saludos tengo un problema con este nuevo script lo que quiero hacer es en la parte del script q dice ///aqui/// necesito q reslut se haga toString() o algo similar ya que el valor lo pasa como [object OBJECT] lo podemos ver cambiando ///aqui/// con un alert('result'); entonces al hacer eso ya me aparece como undefined o algun otro error osea el chiste como le hago para q este script funcione.

Este script lo que hace es cambiar o mas bn dicho traducir los tags que tengan la propiedad name="setlng" ahorita esta de en a es osea ingles a español

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google AJAX Search API Sample</title>
    <script src="http://www.google.com/jsapi"></script>
    <script type="text/javascript">
    
    google.load("language", "1");
    
  function translateComplete(results) {
    var translationDiv = document.getElementsByName("setlng");
      if (!results.error) {
        for (i=0; i < results.responseData.length - 1; i++) {
          y = i + 1;
          var result = results.responseData[y];
       ///aqui///
          translationDiv[i].innerHTML = result.responseData.translatedText;
        }
      }
    }
    
    function initializer() {

      var callbackFunction = 'translateComplete';
      var newScript = document.createElement('script');
      newScript.type = 'text/javascript';
      var source = 'http://ajax.googleapis.com/ajax/services/language/translate' +
                   '?v=1.0&q=';
      var totext = document.getElementsByName("setlng");
        for (x=0;x<totext.length;x++){
      var text = totext[x].innerHTML;
         source = source + '&q=' + text;
        }

          var newBatchParam = '&langpair=en%7Ces';
          source = source + newBatchParam;
      source = source + '&callback=' + callbackFunction;
      newScript.src = source;
      document.getElementsByTagName('head')[0].appendChild(newScript);
    }
    
    google.setOnLoadCallback(initializer);
   
    
    </script>
  </head>
  <body style="font-family: Arial;border: 0 none;">
    <div name="setlng">loding...</div>
    <div name="setlng">loding 2...</div>
    <div name="setlng">loading 3...</div>
    <div name="setlng">loading 4...</div>
    <div name="setlng">loading 5...</div>

<table width="98%" name="setlng">
<tr><td align="center"><h2><strong>Producto</strong></h2></td></tr>
<tr><TD>
<center>
<div class="nav-menu">
<ul>
<li><a href="http://redsombrero.co.nz/index.php?mod=eCommerce&ext=productos&id=1" ><<< Atr&aacute;s</a></li>
<li><a href="http://redsombrero.co.nz/index.php?mod=eCommerce">&Iacute;ndice</a></li>

<li><a href="http://redsombrero.co.nz/index.php?mod=eCommerce&amp;ext=shop">Ver carrito</a></li>
</ul>
</div>
</center>
</TD></tr>
</table> 

  </body>
</html>