Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/02/2014, 08:05
Avatar de Jessi11
Jessi11
 
Fecha de Ingreso: enero-2011
Mensajes: 29
Antigüedad: 13 años, 4 meses
Puntos: 1
Mensaje Respuesta: funcion en nueva pestaña

Gracias Alexis88 ! funcionó de de diez.

Te puedo pedir una cosa más? Intenté validar el formulario de tal manera que si le usuario no inserta texto, aparezca una alerta que indique que debe pegar el TAG. Esto lo hice con Dreamweaver ya que me lo hace de manera automática, pero tengo un problemita, por más que aparezca la advertencia, se sigue abriendo una nueva pestaña, como hago para que esto no pase?

Te dejo el código:
Código HTML:
<!doctype html>
<html>
<head>
<script type="text/javascript">
function verTag(){
		
		var tag = document.getElementById("tag").value;
		
		n = window.open("");
		n.document.write(tag);
	}
	
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' Inserte el TAG.\n'; }
    } if (errors) alert(''+errors);
    document.MM_returnValue = (errors == '');
} }
</script>

</head>

<body>
	<form>
		<div id="area_tag">
			<label> Inserte el TAG</label>
			<textarea id="tag" cols="30" rows="10"></textarea>
		</div> <!-- end of area_tag -->
		<div id="view_tag">
			<input type="button" value="Ver TAG" onclick="verTag();MM_validateForm('tag','','R');return document.MM_returnValue"> 
		</div> <!-- end of view_tag -->
	</form>
</body>
</html> 
Gracias !!