JavaScripts
Texto que aparece dejando mensajes
Texto cambia dejando mensajes de manera espectacular.
Rotador de imágenes
Rota imágenes en forma de cubo, soporta gif y jpg.
<script language="JavaScript1.1"> var specifyimage=new Array() specifyimage[0]="URL DE LA IMAGEN 01" specifyimage[1]="URL DE LA IMAGEN 02" specifyimage[2]="URL DE LA IMAGEN 03" var delay=3000 //3 segundos var count =1; var cubeimage=new Array() for (i=0;i<specifyimage.length;i++){ cubeimage[i]=new Image() cubeimage[i].src=specifyimage[i] } function movecube(){ if (window.createPopup) cube.filters[0].apply() document.images.cube.src=cubeimage[count].src; if (window.createPopup) cube.filters[0].play() count++; if (count==cubeimage.length) count=0; setTimeout("movecube()",delay) } window.onload=new Function("setTimeout('movecube()',delay)") </script> <img src="URL DE LA IMAGEN" name="cube" border=0 style="filter:progid:DXImageTransform.Microsoft.Stretch(stretchStyle='PUSH')">
Botón de múltiples enlaces
Botón que rota enlaces, puedes incluir todos los que quieras.
<font face="Arial, Helvetica, sans-serif" size="2"> <script language="JavaScript"> var timerID = null var timerRunning = false var charNo = 0 var charMax = 0 var lineNo = 0 var lineMax = 3 var lineArr = new Array(lineMax) var urlArr = new Array(lineMax) lineArr[1] = "AyudasHoy 01" urlArr[1] = "URL ENLACE" lineArr[2] = "AyudasHoy 02" urlArr[2] = "URL ENLACE" lineArr[3] = "AyudasHoy 03" urlArr[3] = "URL ENLACE" var lineText = lineArr[1] function StartShow() { StopShow() ShowLine() timerRunning = true } function FillSpaces() { for (var i = 1; i <= lineWidth; i++) { spaces += " " } } function StopShow() { if (timerRunning) { clearTimeout(timerID) timerRunning = false } } function ShowLine() { if (charNo == 0) { if (lineNo < lineMax) { lineNo++ } else { lineNo = 1 } lineText = lineArr[lineNo] charMax = lineText.length } if (charNo <= charMax) { document.formDisplay.buttonFace.value = lineText.substring(0, charNo) charNo++ timerID = setTimeout("ShowLine()", 100) } else { charNo = 0 timerID = setTimeout("ShowLine()", 3000) } } function GotoUrl(url) { top.location.href = url } document.write("<form name="formDisplay">"); document.write("<input type="button" name="buttonFace" value="&{lineText}" size="18" onClick="GotoUrl(urlArr[lineNo])">"); document.write("</form>"); StartShow(); </script></font>
Ventana de alerta en tu web con un mensaje
Cuando un visitante entre a tu Sitio Web le aparecerá una ventana de alerta.
<script language="JavaScript" type="text/javascript"> alert("Pon aquí el mensaje que desees!"); </script>
Mensaje de alerta mediante un botón
Cuando le das clic al botón obtienes una alerta.
<form><input type="button" onclick='alert("Aqui el mesaje de alerta!")' value="Nombre" /> </form>
Abre una ventana pop up
Abre otra sitio & ventana pop up al entrar en tu pagina.
<SCRIPT language=Javascript> open('URL ENLACE','TITULO',"toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,resizable=YES,width=490,height=250");</SCRIPT>
Texto en el titulo de tu navegador
Texto en movimiento en el titulo de tus ventanas parte 1.
<SCRIPT LANGUAGE="JavaScript"> var txt=" AyudasHoy - www.ayudashoy.es.tl -"; var espera=100; var refresco=null; function rotulo_title() { document.title=txt; txt=txt.substring(1,txt.length)+txt.charAt(0); refresco=setTimeout("rotulo_title()",espera);} rotulo_title(); </SCRIPT>
Texto en el titulo de tu navegador
Texto en movimiento en el titulo de tus ventanas parte 2.
<SCRIPT> var titletext="AQUI EL TEXTO QUE QUIERAS" var thetext="" var started=false var step=0 var times=1 function welcometext() { times-- if (times==0) { if (started==false) { started = true; document.title = titletext; setTimeout("anim()",1); } thetext = titletext; } } function showstatustext(txt) { thetext = txt; setTimeout("welcometext()",4000)< times++ } function anim() { step++ if (step==7) {step=1} if (step==1) {document.title='>==='+thetext+'===<'} if (step==2) {document.title='=>=='+thetext+'==<='} if (step==3) {document.title='>=>='+thetext+'=<=<'} if (step==4) {document.title='=>=>'+thetext+'<=<='} if (step==5) {document.title='==>='+thetext+'=<=='} if (step==6) {document.title='===>'+thetext+'<==='} setTimeout("anim()",200); } if (document.title) window.onload=onload=welcometext </SCRIPT>
Bloquear & prohibir usuarios por IP
Con este script puedes prohibirle la entrada a cualquier usuario.
<script type="text/javascript"> var bannedips=["22.22.22.22", "11.11.11.11"] var ip = '186.6.172.223' var handleips=bannedips.join("|") handleips=new RegExp(handleips, "i") if (ip.search(handleips)!=-1){ alert("Lamentamos decirte esto pero estas prohibido!") window.location.replace("http://ayudashoy.es.tl")} // Pagina que llevara al prohibido </script>
Bloquear el botón derecho
Bloquea el uso del botón derecho del Mouse.
<script type="text/javascript"> function IE(e) { if (navigator.appName == "Microsoft Internet Explorer" && (event.button == "2" || event.button == "3")) { return false; } } function NS(e) { if (document.layers || (document.getElementById && !document.all)) { if (e.which == "2" || e.which == "3") { return false; } } } document.onmousedown=IE;document.onmouseup=NS;document.oncontextmenu=new Function("return false"); </script>
Bloquear botón derecho más mensaje de alerta
Esta vez con el botón derecho bloqueado te tira un mensaje alerta.
<script type="text/javascript"> function IE(e) { if (navigator.appName == "Microsoft Internet Explorer" && (event.button == "2" || event.button == "3")) { alert('Mensaje que aparece al hacer click derecho!'); return false; } } function NS(e) { if (document.layers || (document.getElementById && !document.all)) { if (e.which == "2" || e.which == "3") { alert('Boton bloqueado'); return false; } } } document.onmousedown=IE;document.onmouseup=NS;document.oncontextmenu=new Function("return false"); </script>
Imagen que cambia cada cierto tiempo
Con este código puedes tener dos imágenes que se cambia de manera alternativa continuamente.
<script language="JavaScript"> var estado=true; setTimeout("cambio()",500); function cambio() { estado=!estado; if(estado==true) img.src="URL IMAGEN 1" else img.src="URL IMAGEN 2" setTimeout("cambio()",500); }<br /> </script> <img name="img" src="URL IMAGEN 2" width="125" height="125">
Mensaje letra a letra
Muestra un mensaje letra a letra dentro de un campo textarea. Es una forma llamativa de presentar un mensaje.
<SCRIPT LANGUAGE="JavaScript"> var posicion1=0 var posicion2=0 var Retardo; var Fin; var Mensaje; function TipeodeMaquina(NuevoRetardo) { Retardo = NuevoRetardo; if (posicion1 > Mensaje.length) { document.MiFormulario.uterra.value = ''; posicion1 = 0; posicion2 = 0; } else if (Mensaje.substring(posicion1-2,posicion1-1) == '.') { document.MiFormulario.uterra.value = ''; posicion2 = posicion1-1; posicion1++; } else { document.Formulario.uterra.value = Mensaje.substring(posicion1,posicion2); posicion1++; } Fin = setTimeout("TipeodeMaquina(Retardo) ", NuevoRetardo); } </SCRIPT> <BODY onLoad="Mensaje='Gracias por estar con AyudasHoy.'; TipeodeMaquina(110);" onUnload="clearTimeout(Fin)"> <FORM NAME="Formulario"> <TEXTAREA NAME="uterra" COLS="40" ROWS="8" style="font-family: Verdana; color: #008000">
Te pide que aceptes para continuar
Mensaje de alerta súper bueno que te da opciones de aceptar o cancelar las normas de la web etc.
<script language="JavaScript"> var agree=confirm ("Este script te permite avisar a los visitantes sobre el contenido de la pagina aceptándolo o rechzándolo.n"+ "Si no estas de acuerdo pulsa Cancelarn"+ "n"+ "Si tu pagina tiene contenidos no aptos para todos los publicos este es un script idealn"+ "ya que evitas asi que entre quien no quiere ver tales contenicos.n"+ "n"+ "Puedes decir tanto como quieras.n"+ "Pero procura no aburrir contando toda una historia de la Roma Imperial.n"+ "n"+ "Si pulsas en ACEPTAR es por que aceptas el contenido.n"+ "Si pulsas CANCELAR seras enviado a una web apta para todos los publicos."); if (agree) document.write(""); else history.go(location="http://ayudashoy.es.tl"); </script>
Mensaje de despedida
Cuando el visitante abandona tu pagina salta un mensaje de despedida, una buena forma de ser siempre cortes.
<SCRIPT language="JavaScript"> function goAway() { alert('¡Hasta pronto no te olvides de AyudasHoy!'); } </SCRIPT> <body bgcolor="white" onUnload="goAway()">
Reloj digital AM - PM
Reloj con uso horario de 12 horas muy bueno.
<body onLoad="show5()"> <span id="liveclock" style="position:absolute;left:0;top:0;"> </span> <script language="JavaScript"> function show5(){ if (!document.layers&&!document.all&&!document.getElementById) return var Digital=new Date() var hours=Digital.getHours() var minutes=Digital.getMinutes() var seconds=Digital.getSeconds() var dn="AM" if (hours>12){ dn="PM" hours=hours-12 } if (hours==0) hours=12 if (minutes<=9) minutes="0"+minutes if (seconds<=9) seconds="0"+seconds myclock="<font size='2' face='Arial' ><b><font size='1'>www.ayudashoy.es.tl</font></br>"+hours+":"+minutes+":" +seconds+" "+dn+"</b></font>" if (document.layers){ document.layers.liveclock.document.write(myclock) document.layers.liveclock.document.close() } else if (document.all) liveclock.innerHTML=myclock else if (document.getElementById) document.getElementById("liveclock").innerHTML=myclock setTimeout("show5()",1000) } </script>
Calendario del día de hoy
Muestra en un cuadro el año, mes, día del mes y día de la semana.
<script languaje="JavaScript"> mesarray=new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio","Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); diaarray=new Array( "Domingo","Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"); hoy = new Date(); dias = hoy.getDate(); dia = hoy.getDay(); mes = hoy.getMonth(); mes=mesarray[mes]; dia =diaarray[dia]; anno = hoy.getYear(); if (anno <200) anno = anno+1900; document.write('<TABLE WIDTH="60" height="60" BORDER="2" BGCOLOR="#FFFFFF"><TR><TD><CENTER>'); document.write('<FONT SIZE="2" COLOR="#000000"> <B>'+mes+'</B></FONT><br>'); document.write('<FONT SIZE="1" COLOR="#000000">'+anno+'</FONT><br>'); document.write('<FONT SIZE="4" COLOR="#000000" FACE="Arial"><B>'+dias+'</B></FONT><br>'); document.write('<FONT SIZE="1" COLOR="#000000">'+dia+'</FONT><br>'); document.write('</CENTER></TR></TD></TABLE>'); </script>
Cambiar imagen al darle un clic
Cambia la imagen por otra cuando haces clic.
<script language="javascript"> imagen1=new Image imagen1.src="URL IMAGEN 2" imagen2=new Image imagen2.src="URL IMAGEN 1" var i=1; function cambiar() { if (i == 1) { document.images['ejemplo'].src=imagen2.src i=2; } else { document.images['ejemplo'].src=imagen1.src; i=1; } } </script><img src="URL IMAGEN 1" name="ejemplo" onMousedown="cambiar()"">
No dejar entrar a menores de edad a tu sitio web
Sitio contenido solo para mayores de edad este codigo te servida porque le pregunta la edad al visitante y si es menor de edad lo redireciona a la web que tu elijas.
<script language="javascript"> var agePrompt=prompt("¿Cuál es tu edad?"); if (agePrompt>=18) alert('Eres mayor de edad. Tienes permiso para entrar al sitio') else { alert('Eres menor de edad. No puedes entrar') document.location="Aqui pon el sitio al que mandaras a los menores de edad"; } </script>
Botón para al instante subir
Con este javascript es más amigable el subir, ya que da un efecto de ascensor al ascender.
<script type="text/javascript"> (function() { function $(id) { return document.getElementById(id); } function setStyleDisplay(id, status) { $(id).style.display = status; } function goTop(acceleration, time) { acceleration = acceleration || 0.1; time = time || 16; var dx = 0; var dy = 0; var bx = 0; var by = 0; var wx = 0; var wy = 0; if (document.documentElement) { dx = document.documentElement.scrollLeft || 0; dy = document.documentElement.scrollTop || 0; } if (document.body) { bx = document.body.scrollLeft || 0; by = document.body.scrollTop || 0; } var wx = window.scrollX || 0; var wy = window.scrollY || 0; var x = Math.max(wx, Math.max(bx, dx)); var y = Math.max(wy, Math.max(by, dy)); var speed = 1 + acceleration; window.scrollTo(Math.floor(x / speed), Math.floor(y / speed)); if(x > 0 || y > 0) { var invokeFunction = "MGJS.goTop(" + acceleration + ", " + time + ")" window.setTimeout(invokeFunction, time); } } function switchTab(showPanels, hidePanels, activeTab, activeClass, fadeTab, fadeClass) { $(activeTab).className = activeClass; $(fadeTab).className = fadeClass; var panel, panelList; panelList = showPanels.split(','); for (var i = 0; i < panelList.length; i++) { var panel = panelList[i]; if ($(panel)) { setStyleDisplay(panel, 'block'); } } panelList = hidePanels.split(','); for (var i = 0; i < panelList.length; i++) { panel = panelList[i];< if ($(panel)) { setStyleDisplay(panel, 'none'); } } } window['MGJS'] = {}; window['MGJS']['$'] = $; window['MGJS']['setStyleDisplay'] = setStyleDisplay; window['MGJS']['goTop'] = goTop; window['MGJS']['switchTab'] = switchTab; })(); function switchImage(imageId, imageUrl, linkId, linkUrl, preview, title, alt) { if(imageId && imageUrl) { var image = $(imageId); image.src = imageUrl; if(title) { image.title = title; } if(alt) { image.alt = alt; } } if(linkId && linkUrl) { var link = $(linkId); link.href = linkUrl; } } </script> <a style="display:scroll;position:fixed;bottom:10px;left:5px;" title="Subir" href="#" onclick="MGJS.goTop();return false;" id="gotop"><img border="0" src="http://ayudashoy.com.ar/subir.png" alt="Subir" /></a>
Ventana de aviso
En el rincón izquierdo de tu web aparece una ventana de aviso muy buena.
else if (ie4||ns6) crossobj=ns6? document.getElementById("postit") : document.all.postit function closeit(){ if (ie4||ns6) crossobj.style.visibility="hidden" else if (ns4) crossobj.visibility="hide"} function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end))}} return returnvalue;} function showornot(){ if (get_cookie('postdisplay')==''){ showit() document.cookie="postdisplay=yes"}} function showit(){ if (ie4||ns6) crossobj.style.visibility="visible" else if (ns4) crossobj.visibility="show"} if (once_per_browser) showornot() else showit() </script> <script language="JavaScript1.2"> function drag_drop(e){ if (ie4&&dragapproved){ crossobj.style.left=tempx+event.clientX-offsetx+'px' crossobj.style.top=tempy+event.clientY-offsety+'px' return false} else if (ns6&&dragapproved){ crossobj.style.left=tempx+e.clientX-offsetx+'px' crossobj.style.top=tempy+e.clientY-offsety+'px' return false}} function initializedrag(e){ if (ie4&&event.srcElement.id=="postit"||ns6&&e.target.id=="postit"){ offsetx=ie4? event.clientX : e.clientX offsety=ie4? event.clientY : e.clientY tempx=parseInt(crossobj.style.left) tempy=parseInt(crossobj.style.top) dragapproved=true document.onmousemove=drag_drop}} document.onmousedown=initializedrag document.onmouseup=new Function("dragapproved=false") </script>
Impide seleccionar el contenido
Impide seleccionar el contenido de una página ya sean imágenes o texto, con ello evitas que te las puedan copiar.
<script language="Javascript"> function disableselect(e){ return false } function reEnable(){ return true } document.onselectstart=new Function ("return false") if (window.sidebar){ document.onmousedown=disableselect document.onclick=reEnable } </script>