Ejemplos en Javascript

Mensaje typer de formulario

<HTML>
<HEAD>

<TITLE>Ejemplos Javascript: ejemplo pr???¡ctico </TITLE>



</HEAD>

<BODY bgcolor="white">


<script language="JavaScript">
<!--
function initArray() {
 this.length = initArray.arguments.length;
 for (i=0;i<this.length;i++)
  this[i] = initArray.arguments[i];
}

// *** Replace the sample messages with your messages.    ***
// *** You can put as few or as many messages as you want ***

var msg = new initArray("Mensaje 1",
                        "Mensaje 2",
                        "Mensaje 3");

// DEFINE THESE VARIABLES TO CUSTOMIZE AS FOLLOWS:
// start_automatically - start Typing Marquee automatically?
// marq_repeat - repeat after all messages are shown?
// marq_length - length of box
// type_speed - typing speed (175 recommended)
// intermsg_delay - delay between messages (2000 recommended)
// marq_default - message to show when idle

var start_automatically = false;
var marq_repeat = false;
var marq_length = 35;
var type_speed = 175;
var intermsg_delay = 2000;
var marq_default = "Pulsa aqu???­ para empezar o parar...";

function toggle(par) {
 document.marq_form.marq.blur();
 if ((par != null) || (start_automatically)) {
  marq_status = !marq_status;
  if (verify()) {
   cur_msg = 0;
   cur_char = 0;
   type();
  } else {
   marq_status = false;
  }
 }
}
function verify() {
 var valid = true;
 for (j=0;j<msg.length;j++) {
  if (msg[j].length > marq_length) {
   alert("Message "+(j+1)+" is too long! "
    + "You must fix it for the script to run. "
    + "Either shorten the message or increase "
    + "marq_length so it fits.");
   valid = false;
  }
 }
 return valid;
}
function type() {
 if (cur_char >= msg[cur_msg].length) {
  cur_char = 0;
  cur_msg++;
 }
 if (cur_char == 0)
  document.marq_form.marq.value = "";
 if ((cur_msg >= msg.length) && (marq_repeat))
  cur_msg = 0;
 if ((cur_msg<msg.length) && (marq_status)) {
  document.marq_form.marq.value += msg[cur_msg].charAt(cur_char);
  cur_char++;
  if (cur_char >= msg[cur_msg].length)
   setTimeout("type()",intermsg_delay);
  else
   setTimeout("type()",type_speed);
 } else {
  document.marq_form.marq.value = marq_default;
  marq_status = false;
 }
}
var marq_status = false;
var cur_msg = 0;
var cur_char = 0;
document.write('<center><form name="marq_form"> '
 +'<input type="text" name="marq" '
 +'size="'+marq_length+'" value="'+marq_default+'">'
 +'<input type="button" value="Comienza/Para" '
 +'onClick="toggle(true)"></form></center>');
toggle();      
// -->
</script>


</body>
</html>
 

Animaci?n texto