0% found this document useful (0 votes)
54 views

Fecha Y Hora: (M-Javascript)

The document provides code snippets for adding different interactive elements to a website using JavaScript, including: 1) Adding a date and time display that updates automatically; 2) Adding an encoding/decoding text box that can encrypt/decrypt written text with a click of a button; 3) Adding an explanatory text box that pops up descriptions when hovering over certain words or phrases.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Fecha Y Hora: (M-Javascript)

The document provides code snippets for adding different interactive elements to a website using JavaScript, including: 1) Adding a date and time display that updates automatically; 2) Adding an encoding/decoding text box that can encrypt/decrypt written text with a click of a button; 3) Adding an explanatory text box that pops up descriptions when hovering over certain words or phrases.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 14

Fecha y hora ( M-JavaScript )

Para poner una fecha y hora en tu web tienes que poner lo siguiente:

<script language="LiveScript">
<!-- Escondiendo
today = new Date()
document.write("La hora actual es: ",today.getHours(),":",today.getMinutes())
document.write("
La fecha es: ", today.getMonth()+1,"/",today.getDate(),"/",today.getYear());
// se termina de esconder -->
</script>

Caja codificadora ( M-JavaScript )


Para poner una caja codificadora en tu web tienes que poner lo siguiente:

<script language="JavaScript"><!-function codifica(txt) {


var str='',chr;
var i=0,f=txt.length;
while (i<f){
chr=txt.charAt(i);
if (chr=='a')chr='!';
if (chr=='e')chr='';
if (chr=='i')chr='';
if (chr=='o')chr='$';
if (chr=='u')chr='%';
if (chr=='b')chr='';
if (chr=='c')chr='';
if (chr=='d')chr='';
if (chr=='f')chr='';
if (chr=='g')chr='';
if (chr=='h')chr='';
if (chr=='n')chr='';

if (chr=='p')chr='';
if (chr=='r')chr='';
if (chr=='s')chr='';
if (chr=='t')chr='';
if (chr=='1')chr='';
if (chr=='3')chr='';
if (chr=='4')chr='';
if (chr=='5')chr='';
if (chr=='7')chr='';
if (chr=='9')chr='';
if (chr=='0')chr='';
if (chr==' ')chr='';
if (chr=='T')chr='';
if (chr=='M')chr='';
if (chr=='L')chr='';
if (chr=='A')chr='&hibar;';
if (chr=='E')chr='';
if (chr=='Y')chr='';
if (chr=='O')chr='';
if (chr=='J')chr='';
if (chr=='N')chr='';

str=str+chr;
i++;}
document.f.txt.value=str;
}
function decodifica(txt) {
var str='',chr;
var i=0,f=txt.length;
while (i<f){
chr=txt.charAt(i);
if (chr=='!')chr='a';
if (chr=='')chr='e';
if (chr=='')chr='i';
if (chr=='$')chr='o';
if (chr=='%')chr='u';
if (chr=='')chr='b';
if (chr=='')chr='c';
if (chr=='')chr='d';
if (chr=='')chr='f';
if (chr=='')chr='g';
if (chr=='')chr='h';
if (chr=='')chr='n';
if (chr=='')chr='p';
if (chr=='')chr='r';
if (chr=='')chr='s';

if (chr=='')chr='t';
if (chr=='')chr='1';
if (chr=='')chr='3';
if (chr=='')chr='4';
if (chr=='')chr='5';
if (chr=='')chr='7';
if (chr=='')chr='9';
if (chr=='')chr='0';
if (chr=='')chr=' ';
if (chr=='')chr='T';
if (chr=='')chr='M';
if (chr=='')chr='L';
if (chr=='&hibar;')chr='A';
if (chr=='')chr='E';
if (chr=='')chr='Y';
if (chr=='')chr='O';
if (chr=='')chr='J';
if (chr=='')chr='N';
str=str+chr;
i++;}
document.f.txt.value=str;
}

// --></script>
<form name="f">
<div align="left"><table border="0" cellspacing="0">
<TBODY>
<tr>
<td colspan="3"><textarea name="txt" rows="10"
cols="40"></textarea></td>
<td width="20">&nbsp;</td>
<td valign="top"><font size="2" face="Arial"><strong>Pasos
para decodificar/codificar textos:</strong></font> <p><font
size="2" face="Arial"><strong>1.- Seleccionar un
texto </strong></font><font color="#FF8040" size="2"
face="Arial"><strong>control + E</strong></font><font
size="2" face="Arial"><strong><br>
3.- Copiarlo </strong></font><font color="#FF8000"
size="2" face="Arial"><strong>Control + C</strong></font><font
size="2" face="Arial"><strong><br>
4.- Ven a esta pagina<br>
5.- Pincha en cuadro de al lado.<br>
6.- Pegar </strong></font><font color="#FF8000"
size="2" face="Arial"><strong>Control + V</strong></font><font
size="2" face="Arial"><strong><br>
7.- Pincha en </strong></font><font color="#FF8000"

size="2" face="Arial"><strong>Muestra/oculta</strong></font><font
size="2" face="Arial"><strong>.</strong></font></p>
</td>
</tr>
<tr>
<td><p align="center"><input type="button"
name="deco" value="Muestra"
onclick="decodifica(txt.value);"></p>
</td>
<td>&nbsp;</td>
<td><p align="center"><input type="button" name="cod"
value="Oculta" onclick="codifica(txt.value);"> </p>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</TBODY> </table>
</div>
</form>
<SCRIPT language="JavaScript" SRC="/include/frames.js">
</SCRIPT>
<SCRIPT language="JavaScript">

Caja codificadora ( M-JavaScript )


Para poner una caja codificadora en tu web tienes que poner lo siguiente:

<script language="JavaScript"><!-function codifica(txt) {


var str='',chr;
var i=0,f=txt.length;
while (i<f){
chr=txt.charAt(i);
if (chr=='a')chr='!';
if (chr=='e')chr='';
if (chr=='i')chr='';
if (chr=='o')chr='$';
if (chr=='u')chr='%';
if (chr=='b')chr='';
if (chr=='c')chr='';
if (chr=='d')chr='';
if (chr=='f')chr='';
if (chr=='g')chr='';
if (chr=='h')chr='';
if (chr=='n')chr='';

if (chr=='p')chr='';
if (chr=='r')chr='';
if (chr=='s')chr='';
if (chr=='t')chr='';
if (chr=='1')chr='';
if (chr=='3')chr='';
if (chr=='4')chr='';
if (chr=='5')chr='';
if (chr=='7')chr='';
if (chr=='9')chr='';
if (chr=='0')chr='';
if (chr==' ')chr='';
if (chr=='T')chr='';
if (chr=='M')chr='';
if (chr=='L')chr='';
if (chr=='A')chr='&hibar;';
if (chr=='E')chr='';
if (chr=='Y')chr='';
if (chr=='O')chr='';
if (chr=='J')chr='';
if (chr=='N')chr='';

str=str+chr;
i++;}
document.f.txt.value=str;
}
function decodifica(txt) {
var str='',chr;
var i=0,f=txt.length;
while (i<f){
chr=txt.charAt(i);
if (chr=='!')chr='a';
if (chr=='')chr='e';
if (chr=='')chr='i';
if (chr=='$')chr='o';
if (chr=='%')chr='u';
if (chr=='')chr='b';
if (chr=='')chr='c';
if (chr=='')chr='d';
if (chr=='')chr='f';
if (chr=='')chr='g';
if (chr=='')chr='h';
if (chr=='')chr='n';
if (chr=='')chr='p';
if (chr=='')chr='r';
if (chr=='')chr='s';

if (chr=='')chr='t';
if (chr=='')chr='1';
if (chr=='')chr='3';
if (chr=='')chr='4';
if (chr=='')chr='5';
if (chr=='')chr='7';
if (chr=='')chr='9';
if (chr=='')chr='0';
if (chr=='')chr=' ';
if (chr=='')chr='T';
if (chr=='')chr='M';
if (chr=='')chr='L';
if (chr=='&hibar;')chr='A';
if (chr=='')chr='E';
if (chr=='')chr='Y';
if (chr=='')chr='O';
if (chr=='')chr='J';
if (chr=='')chr='N';
str=str+chr;
i++;}
document.f.txt.value=str;
}

// --></script>
<form name="f">
<div align="left"><table border="0" cellspacing="0">
<TBODY>
<tr>
<td colspan="3"><textarea name="txt" rows="10"
cols="40"></textarea></td>
<td width="20">&nbsp;</td>
<td valign="top"><font size="2" face="Arial"><strong>Pasos
para decodificar/codificar textos:</strong></font> <p><font
size="2" face="Arial"><strong>1.- Seleccionar un
texto </strong></font><font color="#FF8040" size="2"
face="Arial"><strong>control + E</strong></font><font
size="2" face="Arial"><strong><br>
3.- Copiarlo </strong></font><font color="#FF8000"
size="2" face="Arial"><strong>Control + C</strong></font><font
size="2" face="Arial"><strong><br>
4.- Ven a esta pagina<br>
5.- Pincha en cuadro de al lado.<br>
6.- Pegar </strong></font><font color="#FF8000"
size="2" face="Arial"><strong>Control + V</strong></font><font
size="2" face="Arial"><strong><br>
7.- Pincha en </strong></font><font color="#FF8000"

size="2" face="Arial"><strong>Muestra/oculta</strong></font><font
size="2" face="Arial"><strong>.</strong></font></p>
</td>
</tr>
<tr>
<td><p align="center"><input type="button"
name="deco" value="Muestra"
onclick="decodifica(txt.value);"></p>
</td>
<td>&nbsp;</td>
<td><p align="center"><input type="button" name="cod"
value="Oculta" onclick="codifica(txt.value);"> </p>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</TBODY> </table>
</div>
</form>
<SCRIPT language="JavaScript" SRC="/include/frames.js">
</SCRIPT>
<SCRIPT language="JavaScript">

Cuadro explicativo ( M-JavaScript )


Para poner un cuadro explicativo en tu web tienes que poner lo siguiente:

en opciones de la web:
onload="escribe(' Explicacin\n -----------\n Pasar el puntero del ratn por encima de los enlaces.');">
en body
<script language="JavaScript"><!-function escribe(frase){document.desplaza.cuadro.value=frase; }
// --></script>
<table border="0">
<tr>
<td width="200"><p align="center"><strong>Opciones.</strong></p>
<p><a href="index.htm"
onmouseover="escribe(' Pgina principal\n ----------------\n\n Cuando hagas Click en este enlace irs
directamente a la pgina de inicio de mi web');">Pgina
principal</a><br>
<a href="index.htm"

onmouseover="escribe(' JavaScript\n -----------\n\n Este enlace te llevar a la pgina de inicio de


Scripts en la que puedes encontrar muchos ms trucos interesantes para realizar e incluir en tus pginas
web');">JavaScripts</a><br>
<a href="glosario_index.htm"
onmouseover="escribe(' Diccionarios\n -------------- \n\n Si tienes alguna duda sobre alguna palabra
que no conoces, aqui encontrars una recopilacin de las palabras ms comunes utilizadas en
Internet.');">Diccionarios</a><br>
</p>
</td>
<td><form name="desplaza">
<p><textarea name="cuadro" rows="8" cols="30"
wrap="physical"></textarea></p>
</form>
</td>
</tr>
</table>

Ejemplo del cuadro (los links no funcionan):

Men Desplegable ( BigAlien)

Para poner un men desplegable en tu web tienes que poner lo siguiente:

<script language="JavaScript" type="text/javascript"><!-function irA(menu){window.location.href =


menu.options[menu.selectedIndex].value;}
// fin de javascript -->
</script>
<form name="formulario">
<p><select name="menu" size="1" onchange="irA(this)"
style="BACKGROUND-COLOR: #ffa54a; COLOR: #000080; FONT-FAMILY:
Verdana, Arial; FONT-SIZE: 9pt; FONT-WEIGHT: bold">
<option selected value>Visitar</option>
<option value="http://www.ole.es">Ol!</option>
<option value="http://www.ozu.es">Oz es</option>
<option value="http://www.ozu.com">Otro com</option>
<option value="http://www.es.lycos.de">Lycos</option>
<option value="http://www.metabusca.com">Metabusca</option>
</select> </p>
</form>
<SCRIPT language="JavaScript" SRC="/include/frames.js">
</SCRIPT>

Ejemplo del men desplegable:

Texto que va apareciendo (M-JavaScript )


Para poner un texto que vaya apareciendo (Ej abajo) en tu web tienes que poner lo siguiente:

<form name="form1" method="get">


<p align="left">&nbsp;<input type="text" name="scrolltext1" value="Este es el
texto que va apareciendo"
size="40"></p>
</form>

Boton que te habla ( BigAlien )


Para poner un boton que te habla en tu web tienes que poner lo siguiente:

<SCRIPT LANGUAGE="JavaScript">
var alerted_already;
var remark;
function theytyped(form) {
for ( j = 1;
j<=remark.length && remark[j]!=form.myoutxt.value;
j++){}
if (j>remark.length)
form.myoutxt.value = "Do not type here!";
return false;
}
function touched_frog() {
if (!alerted_already) {
alert(""+
""+
""+
""+

""+
"");
alerted_already = true;
}
return alerted_already;
}
function compute(form) {
for (var i = 1;
i<=remark.length && remark[i]!=form.myoutxt.value ;
i++){}
if (i==remark.length)
history.back();
if (i==remark.length-1)
alert("Querido amigo/a:"+
"\n\nCreo haberle dicho repetidas veces que deje de pulsarme. "+
"Si vuelve a pulsarme tendre que tomar medidas mas drasticas."+
"\nAtentamente, recibe un cordial saludo.");
if (i<remark.length)
form.myoutxt.value = remark[i+1];
else
form.myoutxt.value = remark[1];
}
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++)
this[i+1] = initArray.arguments[i];
}
remark = new initArray( "Gracias!",
"Una vez mas?!",
"Te dije solo una vez mas!",
"Estas pedo!!!",
"Tu has bebido aceite de colza!",
"Te digo que pares!!.",
"He dicho que te pares!!!",
"Estas sordo??!!!",
"Me tienes hasta los *******!!!",
"Te vas a enterar!!!.",
"Vuelve a pulsarme y veras...!");
alerted_already = false;
// End -->
</SCRIPT>
<BODY>
<FORM name="buttons" method="post" onSubmit="return false">
<input type="button" name="pushme" value="Pulsame"
onClick="compute(this.form)"
return touched_frog()">
<input type="text" value=" "
name="myoutxt"
onBlur="theytyped(this.form)"
onFocus="theytyped(this.form)"
onChange="theytyped(this.form)"
size=45>
</FORM>

<P><BR>
</CENTER>

Para hacer un buen formulario... ( M-JavaScript )


Para poner un formulario en tu web tienes que poner lo siguiente:

<p><strong><u>Libro de visitas</u></strong> </p>


<form action="mailto:tu-direccion-de-correo" method="post">
<table border="0">
<tr><td align="right"><strong>Nombre:</strong></td>
<td><input type="text" size="36" name="nombre"></td>
<td rowspan="4"><p align="center"><input type="reset" value="Borrar Datos"></p>
<p align="center"><input type="submit" value="Enviar Datos"></p></td>
</tr>
<tr>
<td align="right"><strong>Direccin E-mail: </strong></td>
<td><input type="text" size="36" name="direccion"></td>
</tr>
<tr>
<td align="right"><strong>Cmo me has encontrado?: </strong></td>
<td><input type="text" size="36" name="procedencia"></td>
</tr>
<tr>
<td align="right"><strong>Hazme un comentario: </strong></td>
<td><textarea name="comentario" rows="5" cols="30"></textarea></td>
</tr>
</table>
</form>

Numero al Azar ( M-JavaScript )


Para poner un numero al azar en tu web tienes que poner lo siguiente:

<head><script language="LiveScript">function RandomNumber() { today


= new Date(); num= Math.abs(Math.sin(today.getTime())); return num; }
</script></head><body><script language="LiveScript"><!-document.write("Este es un numero al azar:", RandomNumber());//
--></script></body>

Ultima modificacin ( M-JavaScript )


Para poner la fecha de la ltima modificacin en tu web tienes que poner lo siguiente:

<html><body>Esta es una simple pgina en HTML.<br>Ultima


modificacin: <script language="LiveScript"> <!-- oculta el script de los
browsers obsoletos document.write(document.lastModified) // termina de
esconder el contenido --> </script></body> </html>

Preguntar nombre ( M-JavaScript )


Para preguntar algo y despus ponerlo a algu sitio en tu web tienes que poner lo siguiente: (en Head)

<script language="JavaScript">
<!-function namosw_infotext()
{
var username;
var type, i, top, obj;
for (i = 1, top = 0; i < namosw_infotext.arguments.length; i += 2) {
obj = eval('document.'+namosw_infotext.arguments[i]);
if (obj == null) continue;
type = namosw_infotext.arguments[i+1];
if (type == 'username') {
if (username == null)
username = prompt(namosw_infotext.arguments[0], "");
username = (username == null) ? '' : username;
obj.value = username;
} else if (type == 'moddate') {
obj.value = document.lastModified;
} else if (type == 'ipaddr' || type == 'hostname') {
if (navigator.appName == 'Netscape') {
var host = java.net.InetAddress.getLocalHost();
obj.value = (type == 'ipaddr') ? host.getHostAddress() :
host.getHostName();
} else {
obj.value = '';
}
}
}
}
//-->
</script>
</head>

DESPUES, DONDE LO QUIERAS...


<form name="form1" method="get">
<p align="left">&nbsp;<input type="text" name="infotext1"
value="User Name" size="30"
style="text-decoration:none;"></p>
</form>

Nueva v

You might also like