-
SUPREMO KING™.
User deleted
Qui di seguito è proposto un elenco con molteplici script,funzionanti in qualunque sito.
Sul circuito Forumcommunty, funzionano solo quelli della prima lista!ELENCO SCRIPT
Data ultimo aggiornamento archivio: 10/09/2007
Script funzionanti anche nel Circuito Forumfree
Forumcommunity(FC)
[1] Finestra di avviso
[2]Finestre di avviso in sequenza
[3]Link Lampeggianti
[4]Aggiungi ai Preferiti
[5]Data
[6]Fusi orari
[7]Messaggio di benvenuto in base all'ora
[8]Orologio
[9]Script Anti-copiatura
[10]Disabilita tasto destro con messaggio di avviso
[11]Pagina a tutto schermo
[12]Barre di scorrimento colorate
[13]Iframe
[14]Stampa Pagina
[15]Targhette Spente e accese
[16]Targhette sfocate
[17]Giorni mancanti ad una data prestabilita
[18]Messaggio diverso a seconda dell'ora
[19]Scritta scorrevole sul Browser[20]Script in genere per webmaster
[21]Visualizazzioni immagini con menu a discesa
[22]Testo descrittivo del Link al passaggio del mouse
[23]Immagini associate a link
[24]Effetto testo che si accende e si spegne su sfondo nero
[25]Seleziona e/o deseleziona tutti i ceckbox in un solo click
[26]Evidenzia form quando ci clicchiamo dentro
[27]Evitare la scrittura di certe parole nei form
[28]Script che rivela IP del navigatore
[29]Link tooltip destra scorrevole
[29]Effetto tremo sulle immagini andandoci su col mouse
[30]Effetto faro sulle immagini
[31]Effetto riflesso su acqua di immagini
[32]Ingrandimento immagini andandoci su col mouse
[33]Script che chiede conferma prima di inviare dati
[34]Verifica validità di un indirizzo e-mail
[35]Bottoni colorati
[36]Pulsante aggiorna
[37]Creare una textarea con testo da copiare e incollare
[38]Giorno e data sulla barra del titolo
[39]Mirino sulla pagina
[40]Effetto terremoto
[41]Da quanto tempo sei nel mio sito...
[42]Finestra che chiede di compilare i campi lasciati liberi
[43]Script che consente di andare avanti solo con l'accettazione delle condizioni
[44]Verifica validità del numero di Carta di Credito
[45]Grafici in Javascript
[46]Conta caratteri rimanenti
[47]Testo con effetto dissolvenza
[48]Un browser per le vostre immagini
[49]Numero di caratteri minimi inseribili in un modulo
------------------------------------------------UTILI
Finestra di AvvisoCODICE<script LANGUAGE="JavaScript">
window.alert("Your message");
</script>
Finestre di Avviso in sequenzaCODICE<script language="JavaScript">
<!-- Autore: Massimo Giari (webmaster@massimo61.org) -->
<!--
alert("Semplice messaggio di avviso !");
alert("Messaggio di avviso N° 2 !");
alert("Messaggio di avviso N° 3 !");
alert("Penultimo messaggio di avviso !");
alert("Puoi inserire quanti messaggi di avviso vuoi adesso si aprirà la pagina !!!");
// -->
</script>
</head>
<p><center>
<font face="Verdana" size="-2">Free JavaScripts da<br>
<a href="http://www.massimo61.org/">Free Web Upgrade</a></font>
</center><p>
Link LampeggiantiCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">var rate = 20 // Increase amount(The degree of the
transmutation)
var obj // The object which event occured in
var act = 0 // Flag during the action
var elmH = 0 // Hue
var elmS = 128 // Saturation
var elmV = 255 // Value
var clrOrg // A color before the change
var TimerID // Timer ID
if (navigator.appName.indexOf("Microsoft",0) != -1 && parseInt(navigator.appVersion) >= 4)
{Browser = true} else {Browser = false}if (Browser) {document.onmouseover = doRainbowAnchor;
document.onmouseout = stopRainbowAnchor}function doRainbow(){if (Browser && act != 1) {act =
1; obj = event.srcElement; clrOrg = obj.style.color;TimerID =
setInterval("ChangeColor()",100)}}function stopRainbow(){if (Browser && act != 0)
{obj.style.color = clrOrg; clearInterval(TimerID); act = 0}}function doRainbowAnchor(){if
(Browser && act != 1) {obj = event.srcElement; while (obj.tagName != 'A' && obj.tagName !=
'BODY') {obj = obj.parentElement; if (obj.tagName == 'A' || obj.tagName == 'BODY')break}if
(obj.tagName == 'A' && obj.href != '') {act = 1; clrOrg = obj.style.color; TimerID =
setInterval("ChangeColor()",100)}}}function stopRainbowAnchor(){if (Browser && act != 0) {if
(obj.tagName == 'A') {obj.style.color = clrOrg; clearInterval(TimerID); act = 0}}}function
ChangeColor(){obj.style.color = makeColor()}function makeColor(){if (elmS == 0) {elmR =
elmV; elmG = elmV; elmB = elmV}else {t1 = elmV; t2 = (255 - elmS) * elmV / 255; t3 = elmH %
60; t3 = (t1 - t2) * t3 / 60; if (elmH < 60) {elmR = t1; elmB = t2; elmG = t2 + t3}else if
(elmH < 120) {elmG = t1; elmB = t2; elmR = t1 - t3}else if (elmH < 180) {elmG = t1; elmR =
t2; elmB = t2 + t3}else if (elmH < 240) {elmB = t1; elmR = t2; elmG = t1 - t3}else if (elmH
< 300) {elmB = t1; elmG = t2; elmR = t2 + t3}else if (elmH < 360) {elmR = t1; elmG = t2;
elmB = t1 - t3}else {elmR = 0; elmG = 0; elmB = 0}}elmR = Math.floor(elmR); elmG =
Math.floor(elmG); elmB = Math.floor(elmB); clrRGB = '#' + elmR.toString(16) +
elmG.toString(16) + elmB.toString(16); elmH = elmH + rate; if (elmH >= 360)elmH = 0; return
clrRGB}</script>
Esempio:
LINK LAMPEGGIANTE
Aggiungi ai preferitiCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">
var url_del_tuo_forum="http://www.forumfree.net"
var nome_del_tuo_forum="ForumFree.net"
</script>
<script type="text/javascript">function addbookmark(){if
(document.all)window.external.AddFavorite(url_del_tuo_forum,nome_del_tuo_forum)}</script>
<a href="javascript:addbookmark()">Aggiungi il forum ai preferiti</a>
DataCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">today=new Date(); document.write("La data di oggi: ",
today.getDate(),"/",today.getMonth()+1,"/",today.getYear())</script>
Fusi OrariCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">var Oggi = new Date(); var Fuso_orario =
Oggi.getTimezoneOffset()/60; var Ora_corrente=true; var TO = null; function stopclock
(){if(Ora_corrente)clearTimeout(TO); Ora_corrente = false}function startclock
(){stopclock()}function TOfunc(){startclock(); TO = window.setTimeout( "TOfunc()", 1000 );
var scostamento_zona =
document.maschera.zona_mondo.options[document.maschera.zona_mondo.selectedIndex].value; //
document.forms[0].zona_mondo.options[document.forms[0].zona_mondo.selectedIndex].value
var ora_cor = new Date(); var ore = ora_cor.getHours(); var min = ora_cor.getMinutes(); var
secs = ora_cor.getSecond; ore += parseInt(scostamento_zona) - Fuso_orario;
document.maschera.locale.value = ora_cor.toString(); ora_cor.setHours(ore);
document.maschera.mondo.value = ora_cor.toString(); Ora_corrente = true}</script><FORM
NAME="maschera"><table><tr><td Align=center>Ora locale</td><td Align=center>Fusi
orari</td></tr><tr><td Align=center><SELECT NAME="zonalocale" onChange="if (selectedIndex !=
0) {Fuso_orario=parseInt(this.options[selectedIndex].value)}"><OPTION
VALUE="parseInt(Fuso_orario)" SELECTED> Ora Locale</option><OPTION VALUE="1">London
GMT</option><OPTION VALUE="2">Munich, Paris</option><OPTION VALUE="3">Cairo,
Athens</option><OPTION VALUE="4">Kuwait, Moscow</option><OPTION
VALUE="5">Mauritius</option><OPTION VALUE="6">Karachi</option><OPTION VALUE="7">Zone
E7</option><OPTION VALUE="8">Bangkok</option><OPTION VALUE="9">Beijing,
HongKong</option><OPTION VALUE="10">Seoul, Tokyo</option><OPTION
VALUE="11">Sydney</option><OPTION VALUE="12">Zone E12</option><OPTION
VALUE="-11">Wellington</option><OPTION VALUE="-10">Zone W11</option><OPTION
VALUE="-9">Hawaii</option><OPTION VALUE="-8">Anchorage</option><OPTION VALUE="-7">Los
Angles PST</option><OPTION VALUE="-6">Denver MST</option><OPTION VALUE="-5">Chicago
CST</option><OPTION VALUE="-4">New York US EST</option><OPTION
VALUE="-3">Barbados</option><OPTION VALUE="-2">Rio de Janeiro</option><OPTION
VALUE="-1">Zone W2</option><OPTION VALUE="0">Zone W1</option></SELECT></td><td
Align=center><SELECT NAME="zona_mondo" onChange="TO=setTimeout( 'TOfunc()', 1000 )"><OPTION
VALUE="1">London GMT</option><OPTION VALUE="2" SELECTED>Munich, Paris</option><OPTION
VALUE="3">Cairo, Athens</option><OPTION VALUE="4">Kuwait, Moscow</option><OPTION
VALUE="5">Mauritius</option><OPTION VALUE="6">Karachi</option><OPTION VALUE="7">Zone
E7</option><OPTION VALUE="8">Bangkok</option><OPTION VALUE="9" >Beijing,
HongKong</option><OPTION VALUE="10">Seoul, Tokyo</option><OPTION
VALUE="11">Sydney</option><OPTION VALUE="12">Zone E12</option><OPTION
VALUE="-11">Wellington</option><OPTION VALUE="-10">Zone W11</option><OPTION
VALUE="-9">Hawaii</option><OPTION VALUE="-8">Anchorage</option><OPTION VALUE="-7">Los
Angles PST</option><OPTION VALUE="-6">Denver MST</option><OPTION VALUE="-5">Chicago
CST</option><OPTION VALUE="-4">New York US EST</option><OPTION
VALUE="-3">Barbados</option><OPTION VALUE="-2">Rio de Janeiro</option><OPTION
VALUE="-1">Zone W2</option><OPTION VALUE="0">Zone W1</option></SELECT></td></tr><tr><td
Align=center><input type="text" name="locale" value="" size=40="this.blur()"></td><td
Align=center><input type="text" name="mondo" value=""
size=40="this.blur()"></td></tr><tr><td Align=center><INPUT TYPE="button" NAME="Start"
VALUE="Avvia" "TO=setTimeout( 'TOfunc()', 1000 )"></td><td Align=center><INPUT TYPE="reset"
NAME="Reset" VALUE="Resetta"></td></tr></table></form>
Messaggio di Benvenuto in base all'oraCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">adesso = new Date(); ora = adesso.getHours()
document.write("<h2>Messaggio di benvenuto in base all'ora del giorno</h2>")
if (ora > 6 && ora <= 13)document.write ("<P>E' mattina (sei già sveglio ?!), beh, benvenuto
in questa pagina.</CENTER>")
if (ora > 13 && ora <= 19)document.write ("<P>E' pomeriggio (non hai nient'altro da fare
?!), comunque benvenuto in questa pagina.</CENTER>")
if (ora > 19 && ora <= 24)document.write ("<P>E' sera (come non esci ?!), benvenuto lo
stesso in questa pagina.</CENTER>")
if (ora >= 0 && ora <= 6)document.write ("<P>E' notte (che ci fai ancora sveglio !!),
benvenuto (in coma :-)) in questa pagina.</CENTER>")</script>
OrologioCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<form name="clock"="0">
<input type="text" name="face" size=13 value=""></form>
<script type="text/javascript">
var timerID = null
var timerRunning = false
function stopclock (){
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function showtime () {
var now = new Date()
var hours = now.getHours()
var minutes = now.getMinutes()
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " p.m." : " a.m."
document.clock.face.value = timeValue
timerID = setTimeout("showtime()",1000)
timerRunning = true
}
function startclock () {
stopclock()
showtime()
}
startclock();
timerONE=window.setTimeout;
</script>
Script Anti-copiaturaCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">var message=""; function clickIE() {if (document.all)
{(message); return false}} function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {if (e.which==2||e.which==3)
{(message); return false}}} if (document.layers) {document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS} else {document.onmouseup=clickNS;
document.oncontextmenu=clickIE} document.oncontextmenu=new Function("return
false")</script>
Pagina a tutto schermoCODICE<!-- Prelevato nel Forum di Supporto di ForumFree.net e ForumCommunity.net -->
<script type="text/javascript">var url_del_tuo_forum="http://www.forumfree.net"
function espandipagina(){window.open(url_del_tuo_forum,"","channelmode")}</script>
<a href="javascript:espandipagina()">Apri la pagina a tutto schermo</a>
Barra di scorrimento colorataCODICE<!-- prelevato su http://www.web-link.it -->
<style type="text/css">
<!--
body {
scrollbar-3dlight-color: #C0C0C0;
scrollbar-arrow-color: #000000;
scrollbar-base-color: #FF9933;
scrollbar-darkshadow-color: #E86010;
scrollbar-face-color: #FF9933;
scrollbar-highlight-color: #FFFFFF;
scrollbar-shadow-color: #E86010;
scrollbar-track-color: #FF9933;
}
-->
</style>
IframeCODICE<iframe width="xxx" height="yyy" name="nomeframe"
src="pagina_1.htm" marginwidth="0" marginheight="0"
scrolling="yes" frameborder="0"></iframe>
Stampa PaginaCODICE<script language="Javascript1.2" type="text/javascript">
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
var message = "Stampa questa pagina";
function printpage() {
window.print();
}
document.write("<form><input type=button "
+"value=""+message+"" onClick="printpage()"></form>");
</script>
Disabilita tasto destro del mouse con messaggio di
avviso
Da inserire In cima al forum...al posto di "Non copiarmi!" puoi mettere quello che
vuoi tuCODICE<head>
<script type="text/javascript">
<!--
function click() {if (event.button==2) {alert('Non copiarmi!')}}
document.onmousedown=click
// --></script>
</head>
Targhette spente e accese
Da inserire in amministrazione -> modifica colori e stili -> alla fine del codice CSS,
singolarmente.CODICE.web a:link img, .web a:visited img {filter:alpha(opacity=30); -moz-opacity: 0.5;
opacity: 0.5}
.web a:hover img {filter:alpha(opacity=100); -moz-opacity: 1.0; opacity: 1.0}
Targhette sfocate
Da inserire in amministrazione -> modifica colori e stili -> alla fine del codice CSS,
singolarmente.CODICEa:hover .s {filter: blur}
Giorni mancanti ad una data prestabilitaCODICE<script language="JavaScript" type="text/javascript">
<!-- // Prelvato su [URL=http://www.ininternet.org]http://www.ininternet.org[/URL]
today = new Date()
wbl = new Date("August 18, 2003") // fra le virgolette mettete la vostra data
mancano = (wbl.getTime() - today.getTime()) / (1000*60*60*24);
mancano = Math.round(mancano);
// alla riga sotto potete cambiare il messaggio lasciando inalterata la variabile +mancano+
document.write("<center>Esempio: Restano <strong>"+mancano+"</strong> giorni al compleanno
del sito 100% </center>");
// end script -->
</script>
Messaggio diverso a seconda dell'oraCODICE<script language="JavaScript" type="text/javascript">
<!-- http://www.ininternet.org
document.write("<CENTER><p>");
giorno = new Date();
ora = giorno.getHours();
if(ora < 6)
{
document.write("il tuo messaggio se prima delle ore 6");
}
else
if(ora < 12)
{
document.write("il tuo messaggio dalle 6 alle 12");
}
else
if(ora < 18)
{
document.write("il tuo messaggio dalle 12 alle 18");
}
else
{
document.write("il tuo messaggio in tutti gli altri orari");
}
document.write("</CENTER></p>");
// -->
</SCRIPT>
scritta scorrevole sul BrowserCODICE<script language="JavaScript" type="text/javascript">
<!-- http://www.ininternet.org
<!-- Begin
var message = new Array();
// Set your messages you want typed into the title bar below.
// To add more messages, just add more elements to the array.
message[0] = "Benvenuti su GamesTribe";
message[1] = "Giochi";
message[2] = "Programmi";
message[3] = "Video";
message[4] = "Risorse & Pokemon";
message[5] = "e molto altro...";
// Set the number of repetitions (how many times a given message is typed out
// before moving onto the next message).
var reps = 1;
var speed = 200;// Set the overall typing speed (larger number = slower action).
var hold = 8 // set the length of time to display the whole phrase before retyping (larger
number = longer)
// DO NOT EDIT BELOW THIS LINE.
var p = message.length;
var q = 0;
var r = 0;
var C = 0;
var mC = 0;
var s = 0;
var sT = null;
if (reps < 1) {
reps = 1;
}
function setMessage() {
typing = message[mC];
q = typing.length;
r = q + hold;
typeMessage();
}
function typeMessage() {
if (s > r) {
s = 0;
}
if (s > q) {
document.title = '|- '+ typing +' - - -';
}
else {
document.title = '|- '+ typing.substr(0,s)+' - - -';
}
if (C < (r * reps)) {
sT = setTimeout("typeMessage()", speed);
C++;
s++;
}
else {
C = 0;
s = 0;
mC++;
if(mC > p - 1) {mC = 0;}
sT = null;
setMessage();
}
}
setMessage();
// End -->
</script>
Visualizazzioni immagini con menu a discesa
>>ESEMPIO<<CODICE<html><head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<style type=text/css>A:link {
TEXT-DECORATION: none
}
A:visited {
TEXT-DECORATION: none
}
A:hover {
TEXT-DECORATION: underline
}
</style>
<script>
function articolo(str) {
searchWin =
window.open(str,'articolo','scrollbars=no,resizable=yes,width=485,height=300,status=no,locat
ion=no,toolbar=no');
// searchWin.refer = self;
}
</script>
<script language=javascript>
<!--
function showimage()
{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value
}
//-->
</script>
<meta content="MSHTML 5.50.4134.100" name=GENERATOR></head>
<body vLink=blue link=blue bgColor=white>
<div align=center><font face=Arial size=4>
<form name=mygallery><select onchange=showimage() size=1 name=picture> <option
value=http://www.giorgiotave.it/script/javascript/visual/immagine01.jpg>Prima <option
value=http://www.giorgiotave.it/script/javascript/visual/immagine02.jpg>Seconda <option
value=http://www.giorgiotave.it/script/javascript/visual/immagine03.jpg>Terza </form><img
height=100
alt="L'immagine appare qui" src="immagine01.jpg" width=150 border=0
name=pictures> </body></html>
Immagini associate a link
>>ESEMPIO A QUESTO
SCRIPT<<CODICE<html>
<head>
<title>Prova visualizzazione banner (1)</title>
<style>
a:link {
color: #000000; font-weight: bold; text-decoration: none
}
a:visited {
color: #000000; font-weight: bold; text-decoration: none
}
a:hover {
color: #3366ff; font-weight: bold; text-decoration: underline
}
</style>
<script language=Javascript>
<!--
var banner1=new Object;
banner1.Url="figure/auto.gif";
banner1.Img=new Image();
banner1.Img.src=banner1.Url;
banner1.Titolo="Gita in auto";
banner1.Destinazione="auto.htm";
var banner2=new Object;
banner2.Url="figure/mare.gif";
banner2.Img=new Image();
banner2.Img.src=banner2.Url;
banner2.Titolo="Gita al mare";
banner2.Destinazione="mare.htm";
var banner3=new Object;
banner3.Url="figure/neve.gif";
banner3.Img=new Image();
banner3.Img.src=banner3.Url;
banner3.Titolo="Gita in montagna";
banner3.Destinazione="neve.htm";
var selez=banner1;
function Swap(banner)
{
if (document.images!=null)
{
selez=banner;
document.images[0].src=banner.Img.src;
document.images[0].alt=banner.Titolo;
}
}
function Richiama()
{
window.location.replace(selez.Destinazione);
}
// -->
</script>
</head>
<body bgColor=#ffffff text=#000000>
<center>
<font face="Verdana, Arial, Helvetica, sans-serif" size="5"
color="#ff0000"><b>Banner e scritte</b>
<p>
<table border=0 cellPadding=5 cellSpacing=0 width=600>
<tr>
<td vAlign=top>
<p>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="green"><b><i>Quando
si fa passare il puntatore del mouse su una delle due scritte qui sotto, sulla destra
compare la figura corrispondente.</i></b></font>
<p>
<a href="javascript:Richiama()" onmouseover=Swap(banner1)>
<b><font face="Verdana, Arial, Helvetica, sans-serif" font size="2">Chi vuole fare
una gita in auto, clicchi qui.</font></b></a>
<p>
<a href="javascript:Richiama()" onmouseover=Swap(banner2)>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Chi invece preferisce
il mare, clicchi qui.</b></font></a>
<p>
<a href="javascript:Richiama()" onmouseover=Swap(banner3)>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Chi ama la montagna,
clicchi qui.</b></font></a>
<p>
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"
color="green"><b><i>Cliccando
poi sulla scritta o sulla relativa figura si passa alla pagina
corrispondente.</i></b>
<p><font size="1" color=black>Immagini da Adobe PageMill 3.0</font></font>
</td>
<td>
<script language=javascript>
document.write("<a href='javascript:Richiama()'><IMG src='" + banner1.Img.src +
"' width=198 height=227 border=0></a>");
</script>
</td>
</tr>
</table>
</center>
</body>
</html>
Effetto testo che si accende e si spegne su sfondo
nero
>>ESEMPIO DI QUESTO SCRIPT<<CODICEvar to = 22;
var delay = 10;
var glowColor = "FFFF00";
var i = to;
var j = 0;
textPulseDown();
function textPulseUp()
{
if (!document.all)
return
if (i < to)
{
theText.style.filter = "Glow(Color=" + glowColor + ", Strength=" + i + ")";
i++;
theTimeout = setTimeout('textPulseUp()',delay);
return 0;
}
if (i = to)
{
theTimeout = setTimeout('textPulseDown()',delay);
return 0;
}
}
function textPulseDown()
{
if (!document.all)
return
if (i > from)
{
theText.style.filter = "Glow(Color=" + glowColor + ", Strength=" + i + ")";
i--;
theTimeout = setTimeout('textPulseDown()',delay);
return 0;
}
if (i = from)
{
theTimeout = setTimeout('textPulseUp()',delay);
return 0;
}
}
//-->
</script>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
Seleziona e/o deseleziona tutti i ceckbox in un solo
click
>>ESEMPIO DI QUESTO SCRIPT>>CODICE<html>
<head>
<script type="text/javascript">
function checkTutti() {
with (document.modulo) {
for (var i=0; i < elements.length; i++) {
if (elements[i].type == 'checkbox' && elements[i].name == 'cb')
elements[i].checked = true;
}
}
}
function uncheckTutti() {
with (document.modulo) {
for (var i=0; i < elements.length; i++) {
if (elements[i].type == 'checkbox' && elements[i].name == 'cb')
elements[i].checked = false;
}
}
}
</script>
</head>
<body>
<br>
Un semplice script per selezionare tutti i box con un solo clic.<br>
<br>
<br>
<form name="modulo" action="">
<input name="cb" type="checkbox" value="1"><br>
<input name="cb" type="checkbox" value="2"><br>
<input name="cb" type="checkbox" value="3"><br>
<input name="cb" type="checkbox" value="4"><br>
<input name="cb" type="checkbox" value="5"><br>
<input name="cb" type="checkbox" value="6"><br>
<input name="cb" type="checkbox" value="7"><br>
<input name="cb" type="checkbox" value="8"><br>
<input name="cb" type="checkbox" value="9"> <br>
<input type="button" value="Seleziona tutti" onclick="checkTutti()"><br><br>
<input type="button" value="Deseleziona tutti" onclick="uncheckTutti()">
</form>
</body>
</html>
Evidenzia form quando ci clicchiamo dentro
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript1.2">
//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com
var highlightcolor="red"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/
//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}
//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}
</script>
</head>
<body>
<br>
Script che evidenzia i form quando ci clicchiamo dentro.<br>
<br>
<br>
<form onKeyUp="highlight(event)" onClick="highlight(event)">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<textarea>Esempio con textarea</textarea>
</form>
</BODY>
</HTML>
Evitare la scrittura di certe parole nei form
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<SCRIPT LANGUAGE= "JavaScript">
var k = 3; //il numero delle parole. Da variare se ne inserite di più o meno.
var isProfane = new makeArray(k);
var word = new makeArray(k);
function checkForProfanity(elnum) {
var temp = document.forms[0].elements[elnum].value;
temp = temp.toLowerCase();
word[1] = "ciao";
word[2] = "salve";
word[3] = "addio";
for (var j = 1; j <= k; j++) {
isProfane[j] = temp.indexOf(word[j]);
}
for (var j = 1; j <= k; j++) {
if (isProfane[j] != -1) {
alert("Non puoi usare il termine '"+word[j]+"'.");
document.forms[0].elements[elnum].value = "";
j = k + 1;
document.forms[0].elements[elnum].focus();
}
else {}
}
}
function makeArray(n) {
this.length = n
for (var i = 1; i<=n; i++) {
this[i] = new String();
}
return this
}
</SCRIPT>
</head>
<body>
<br>
Con questo semplice script è possibile evitare che nel form siano scritte delle parole.<br>
Provate a scrivere "ciao" oppure "salve" oppure "addio"<br>
<br>
<br>
<form method="POST">
<input name="Name" maxlength="45" size="17" onblur="checkForProfanity(0);">
<input type="SUBMIT" value="Submit">
</form>
</BODY>
</HTML>
Script che rivela IP del navigatoreCODICE<html>
<head>
<title>35 Vari</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
echo $REMOTE_ADDR;
?>
</body>
</html>
Link tooltip destra scorrevole
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<html>
<head>
</head>
<body>
<br><br><br><br>
<SCRIPT>
<!--
if (!document.layers&&!document.all)
event="test"
function showtip2(current,e,text){
if (document.all&&document.readyState=="complete"){
document.all.tooltip2.innerHTML='<marquee style="border:1px solid black">'+text+'</marquee>'
document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
document.all.tooltip2.style.visibility="visible"
}
else if (document.layers){
document.tooltip2.document.nstip.document.write('<b>'+text+'</b>')
document.tooltip2.document.nstip.document.close()
document.tooltip2.document.nstip.left=0
currentscroll=setInterval("scrolltip()",100)
document.tooltip2.left=e.pageX+10
document.tooltip2.top=e.pageY+10
document.tooltip2.visibility="show"
}
}
function hidetip2(){
if (document.all)
document.all.tooltip2.style.visibility="hidden"
else if (document.layers){
clearInterval(currentscroll)
document.tooltip2.visibility="hidden"
}
}
function scrolltip(){
if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width)
document.tooltip2.document.nstip.left-=5
else
document.tooltip2.document.nstip.left=150
}
-->
</SCRIPT>
<DIV id=tooltip2
style="VISIBILITY: hidden; WIDTH: 150px; CLIP: rect(0px 150px 50px 0px); POSITION: absolute;
BACKGROUND-COLOR: lightblue"><LAYER
bgColor="lightblue" width="1000px" name="nstip"></LAYER></DIV><BR><BR><A
onmouseover="showtip2(this,event,'INSERISCI QUI IL TUO TESTO')"
onmouseout=hidetip2() href="#">Passa qui</A>
</body>
</html>
Effetto tremo sulle immagini andandoci su col
mouse
>>EFFETTO DI QUESTO SCRIPT<<CODICE<html>
<head>
</head>
<body>
<br><br><br><br><br><br>
<style>
.shakeimage{
position:relative
}
</style>
<script language="JavaScript1.2">
<!--
var rector=3
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
-->
</script>
<img src="prova1.jpg" class="shakeimage" onMouseover="init(this);rattleimage()"
onMouseout="stoprattle(this);top.focus()" onClick="top.focus()" width="74" height="119">
</body>
</html>
Effetto faro sulle immagini
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<html>
<head>
</head>
<body>
<br><br><br><br><br><br>
<style>
<!--
#myimage{
filter:light
}
-->
</style>
<img id="myimage" src="immagine01.jpg" width="464" height="432">
<script language="JavaScript1.2">
<!--
s = 50; // the size of the spotlight
vp = 10; // the visibility percent of the picture
startx = 0; // the top position of your sportlight into the image (on start)
starty = 0; // the left position of your spotlight into the image (on start)
var IE = document.all?true:false
function moveL()
{
xv = tempX;
yv = tempY;
myimage.filters.light.MoveLight(1,xv,yv,s,true);
}
if (IE&&myimage.filters)
document.all.myimage.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0
function getMouseXY(e) {
tempX = event.offsetX
tempY = event.offsetY
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
if (t)
{
moveL();
}
return true
}
var xv = startx;
var yv = starty;
var t= true;
if (IE&&myimage.filters){
myimage.style.cursor="hand";
myimage.filters.light.addAmbient(255,255,255,vp)
myimage.filters.light.addPoint(startx,starty,s,255,255,255,255)
}
-->
</script>
</body>
</html>
Effetto riflesso accqua si immagini
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<html>
<head>
</head>
<body>
<br><br><br><br>
<img id="reflect" src="prog.jpg" width="152" height="24">
<br>
<script language="JavaScript1.2">
<!--
function f1(){
setInterval("mdiv.filters.wave.phase+=10",100);
}
if (document.all){
document.write('<img id=mdiv src="'+document.all.reflect.src+'"
style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">')
window.onload=f1
}
-->
</script>
</body>
</html>
Ingrandimento immagine andandoci su col mouse
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<html>
<head>
<script language="JavaScript">
<!--
//funzione che ingrandisce
function lentep() {
//l'ingrandimento avviene moltiplicando per 2 i valori
//di altezza e larghezza dell'immagine
document.img1.width=document.img1.width*2
document.img1.height=document.img1.height*2
}
//funzione che rimpicciolisce
function lentem() {
//idem come sopra ma dividendo per 2
document.img1.width=document.img1.width/2
document.img1.height=document.img1.height/2
}
-->
</script>
</head>
<body>
<br><br><br><br><br><br><br>
<center>
<h2>Lente di ingrandimento su immagine</h2>
<br>
<a href="#" onMouseOver="lentep()" onMouseOut="lentem()">
<img name="img1" src="prova1.jpg" width=120 height=80 border=1>
</a>
</center>
</body>
</html>
Script che chiede conferma prima di inviare
dati
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<SCRIPT LANGUAGE="JavaScript">
function confirmAction()
{
action = confirm('Ok per continuare, Cancel per uscire')
if (action==true)
parent.self.location.href = 'a_page.htm';
if (action==false)
alert('Alla prossima');
}
</SCRIPT>
<FORM>
<INPUT TYPE="button" NAME="link" VALUE="Click Here" onclick="confirmAction()">
</FORM>
Verifica validità di un indirizzo e-mail
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<font size="2" face="Arial" color="#FF0000">
<form name="TheForm">
<input type="text" name="nm" size="33"> Your Name
<br><br>
<input type="text" name="em" size="33"> E-mail address
<br>
<input type="text" name="emx" size="33"> Re-enter to confirm
<br><br>
<input type="button" value="Submit" name="SB" onClick="sendOff();">
<script language="JavaScript1.2">
var good;
function checkEmailAddress(field)
{
var goodEmail =
field.value.match(/b(^(S+@).+((.com)|(.net)|(.edu)|(.mil)|(.gov)|(.org)|(..{2,2}))$
)b/gi);
if (goodEmail)
{
good = true
}
else
{
alert('Please enter a valid e-mail address.')
field.focus()
field.select()
good = false
}
}
function sendOff()
{
nmcheck = document.TheForm.nm.value
if (nmcheck.length < 1)
{
alert('Please enter your name.')
return
}
good = false
checkEmailAddress(document.TheForm.em)
if ((document.TheForm.em.value == document.TheForm.emx.value) && (good))
{
alert('Name and email address fields verified good.')
}
if ((document.TheForm.em.value != document.TheForm.emx.value) && (good))
{
alert('Both e-mail address entries must match.')
}
}
</script>
</form>
</font>
Testo descrittivo del Link al passaggio del
mouse
>>ESEMPIO DI
QUESTO SCRIPT<<CODICE<html>
<head><title>Tooltip</title></head>
<script>
var nn = (document.layers) ? 1 : 0;
var ie = (document.all) ? 1 : 0;
var coord_x = 0;
var coord_y = 0;
var auto_close = null;
var inizio_hint = '';
var fine_hint = '';
var supporto = '<table border="0" cellpadding="0"
cellspacing="0"><tr><td></td></tr></table>';
if (ie)
{
document.write('<span id="hint_txt" style="position: absolute; top: 0; left: 0;
visibility: hidden; z-index: 99"></span>');
}
if (nn)
{
document.write('<layer id="hint_txt" top="0" left="0" visibility="hide"
zindex="99"></layer>');
}
inizio_hint += '<table border="0" cellpadding="0" cellspacing="0">';
inizio_hint += '<tr>';
inizio_hint += '<td bgcolor="#E0E0E0" width="1" height="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
inizio_hint += '</tr>';
inizio_hint += '<tr>';
inizio_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#FFFFE6" height="3" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
inizio_hint += '</tr>';
inizio_hint += '<tr>';
inizio_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#FFFFE6" width="5" nowrap>' + supporto + '</td>';
inizio_hint += '<td bgcolor="#FFFFE6" height="13"><font face="MS Sans Serif, Verdana, Arial"
size="1" color="#000000">';
fine_hint += '</font></td><td bgcolor="#FFFFE6" width="5" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
fine_hint += '</tr>';
fine_hint += '<tr>';
fine_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#FFFFE6" height="3" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
fine_hint += '</tr>';
fine_hint += '<tr>';
fine_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
fine_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
fine_hint += '</tr>';
fine_hint += '</table>';
if (ie)
document.onmousemove = get_coord;
if (nn)
{
document.captureEvents (Event.MOUSEMOVE);
document.onmousemove = get_coord;
}
function get_coord (e)
{
if (ie)
{
coord_x = event.clientX + document.body.scrollLeft;
coord_y = event.clientY + document.body.scrollTop;
event.srcElement.onmouseout = off_hint;
}
if (nn)
{
coord_x = e.pageX + window.pageXOffset;
coord_y = e.pageY + window.pageYOffset;
e.target.onmouseout = off_hint;
}
return true;
}
function hint (testo)
{
if (typeof testo != 'undefined')
{
if (testo == "")
testo = " ";
clearTimeout(auto_close);
auto_close = null;
if (ie)
{
hint_txt.innerHTML = inizio_hint + testo + fine_hint;
hint_txt.style.pixelTop = coord_y + 15;
hint_txt.style.pixelLeft = coord_x;
hint_txt.style.visibility = "visible";
}
if (nn)
{
document.layers.hint_txt.document.open();
document.layers.hint_txt.document.write(inizio_hint + testo + fine_hint);
document.layers.hint_txt.document.close();
document.layers.hint_txt.left = coord_x;
document.layers.hint_txt.top = coord_y + 15;
document.layers.hint_txt.visibility = "show";
}
auto_close = setTimeout("off_hint()", 10000);
}
}
function off_hint ()
{
if (ie) hint_txt.style.visibility = "hidden";
if (nn) document.layers.hint_txt.visibility = "hide";
}
</script>
<p><a href="javascript:void(0)" onmouseover="hint('INSERIRE QUI IL MESAGGIO')">PASSA CON IL
MOUSE SUL LINK...</a></p>
</html>
Bottoni colorati
>>ESEMPIO DI QUESTO SCRIPT<<CODICE<script language=JavaScript>
// varibili
m_over_col = "#ff9944";
m_out_col = "#c0c0c0";
m_down_col = "#ee5555";
dow_key = '';
window.onload = recolor_butt;
function recolor_butt()
{
len_all = document.all.length;
for (i=0; i<len_all; i++)
{
id = document.all[i].id;
if (id.indexOf('butt') == 0)
{
document.all[i].style.background = m_out_col;
}
}
}
function document.onmouseover()
{
id = window.event.srcElement.id;
if (id.indexOf('butt') == 0)
{
if (dow_key == id)
{
return;
}
document.all[id].style.background = m_over_col;
}
}
function document.onmouseout()
{
id = window.event.srcElement.id;
if (id.indexOf('butt') == 0)
{
if (dow_key == id)
{
return;
}
document.all[id].style.background = m_out_col;
}
}
function document.onmousedown()
{
id = window.event.srcElement.id;
if (id.indexOf('butt') == 0)
{
if (dow_key! = '')
{
document.all[dow_key].style.background = m_out_col;
}
dow_key = id;
document.all[id].style.background = m_down_col;
}
}
</script>
Pulsante Aggiorna
>>ESEMPIO
DI QUESTO SCRIPT<<CODICE<form method="post" action="">
<input type="button" value="AGGIORNA" onClick="location.reload()">
</form>
Creare una textarea con testo da copiare e
incollare
CODICE<SCRIPT language="JavaScript"><!--
function SelezionaTextArea() {
document.frmchat.cpcodechat.select(); document.frmchat.cpcodechat.focus();
}
function Copia() {
SelezionaTextArea();
textRange = document.frmchat.cpcodechat.createTextRange();
textRange.execCommand("RemoveFormat");
textRange.execCommand("Copy");
alert("Il testo è stato copiato. Incollalo dove vuoi.");
}
--></SCRIPT>
<FORM name="frmchat">
<TEXTAREA name="cpcodechat" cols="55" rows="10" wrap="off" contenteditable="false"
style="color:#000080;background-color:#f9f9f9">
TESTO DA COPIARE
</TEXTAREA>
<br>
<script language="JavaScript" type="text/javascript">
<!--
if ((navigator.appName=="Microsoft Internet Explorer")&&(parseInt(navigator.appVersion)>=4))
{
document.write('<INPUT type="button" value=" Copia in memoria " onClick="Copia();">');
} else {
document.write('<INPUT type="button" value="Seleziona il testo"
onClick="SelezionaTextArea();">');
}
// -->
</script>
</form>
Giorno e data sulla barra del titoloCODICE<script language="JavaScript1.2">
<!--
var isnMonth = new
Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre",
"Ottobre","Novembre","Dicembre");
var isnDay = new
Array("Domenica","Lunedi","Martedi","Mercoledi","Giovedi","Venerdi","Sabato","Domenica");
today = new Date () ;
Year=today.getYear();
Date=today.getDate();
if (document.all)
document.title="Oggi : "+isnDay[today.getDay()]+", "+Date+"
"+isnMonth[today.getMonth()]+Year+""
// -->
</SCRIPT>
Mirino sulla paginaCODICE<style>
<!--
#leftright, #topdown{
position:absolute;
left:0;
top:0;
width:1px;
height:1px;
layer-background-color:black;
background-color:black;
z-index:100;
font-size:1px;
}
-->
</style>
</HEAD>
<BODY bgcolor="white" >
<div id="leftright" style="width:expression(document.body.clientWidth-2)"></div>
<div id="topdown" style="height:expression(document.body.clientHeight-2)"></div>
<script language="JavaScript1.2">
<!--
if (document.all&&!window.print){
leftright.style.width=document.body.clientWidth-2
topdown.style.height=document.body.clientHeight-2
}
else if (document.layers){
document.leftright.clip.width=window.innerWidth
document.leftright.clip.height=1
document.topdown.clip.width=1
document.topdown.clip.height=window.innerHeight
}
function followmouse1(){
//move cross engine for IE 4+
leftright.style.pixelTop=document.body.scrollTop+event.clientY+1
topdown.style.pixelTop=document.body.scrollTop
if (event.clientX<document.body.clientWidth-2)
topdown.style.pixelLeft=document.body.scrollLeft+event.clientX+1
else
topdown.style.pixelLeft=document.body.clientWidth-2
}
function followmouse2(e){
//move cross engine for NS 4+
document.leftright.top=e.y+1
document.topdown.top=pageYOffset
document.topdown.left=e.x+1
}
if (document.all)
document.onmousemove=followmouse1
else if (document.layers){
window.captureEvents(Event.MOUSEMOVE)
window.onmousemove=followmouse2
}
function regenerate(){
window.location.reload()
}
function regenerate2(){
setTimeout("window.onresize=regenerate",400)
}
if ((document.all&&!window.print)||document.layers)
//if the user is using IE 4 or NS 4, both NOT IE 5+
window.onload=regenerate2
//-->
</script>
</body>
</html>
Effetto terremotoCODICE<script LANGUAGE="JavaScript" type="text/javascript">
<!-- Start script
function terremoto(x) {
browser = (navigator.appName == "Microsoft Internet Explorer") &&
(parseInt(navigator.appVersion) >= 4);
if (browser) {
for (i = 10; i > 0; i--) {
for (j = x; j > 0; j--) {
self.moveBy(0,i);
self.moveBy(i,0);
self.moveBy(0,-i);
self.moveBy(-i,0);
}
}
}
}
terremoto(12);
// end script -->
</script>
Da quanto tempo sei nel mio sito...CODICE<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
var enabled = 0;
var ora_ini = new Date();
var tot = 0;
var ID = null;
function IDciclo()
{
ID = window.setTimeout( "IDciclo()", 1000 );
var ora = new Date();
var tot = ((ora.getHours() - ora_ini.getHours())*3600) + ((ora.getMinutes() -
ora_ini.getMinutes())*60) +(ora.getSeconds() - ora_ini.getSeconds());
document.forms[0].elements[0].value = ora_ini.toString();
document.forms[0].elements[1].value = ora.toString();
var s = tot%60;
var h = Math.round((tot/3600)-0.5);
var m = Math.round((tot/60)+0.5) - (h*60);
var hrs=ora.getHours()
var giorno=ora.getDay()
var scatti = 1+Math.round((tot/400)-0.5);
document.forms[0].elements[2].value = "ore: "+h+' minuti: '+m+' secondi: '+s;
document.forms[0].elements[3].value = "secondi: "+tot;
document.forms[0].elements[4].value = scatti;
if (hrs>=8 && hrs<18) {
var scatti = 1+Math.round((tot/220)-0.5);
document.forms[0].elements[4].value = scatti}
if (giorno==6 && hrs>=8 && hrs<13) {
var scatti = 1+Math.round((tot/220)-0.5);
document.forms[0].elements[4].value = scatti}
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" OnLoad="setTimeout('IDciclo()', 1000)" >
<FORM>
<P ALIGN=left>
<TABLE COLSPAN=2>
<TR>
<TD>Ora inizio accesso:</TD>
<TD>
<INPUT type="text" name="t1" value="" size=25 onFocus="this.blur()" ></TD>
<TD>Ora attuale:</TD>
<TD>
<INPUT type="text" name="t2" value="" size=25 onFocus="this.blur()" ></TD>
<TD>Tempo accesso:</TD>
<TD>
<INPUT type="text" name="t3" value="" size=25 onFocus="this.blur()" ></TD>
<TD>Secondi:</TD>
<TD>
<INPUT type="text" name="t4" value="" size=25 onFocus="this.blur()" ></TD>
</TR>
<TR>
<TD>Scatti telefonici:</TD>
<TD>
<INPUT type="text" name="t4" value="" size=25 onFocus="this.blur()" ></TD>
</TR>
</TABLE>
</FORM>
</BODY></HTML>
Finestra che chiede di compilare i campi lasciati
liberiCODICE<script language="JavaScript">
function formCheck(formobj)
{
//1) Enter name of mandatory fields
var fieldRequired = Array("FirstName", "LastName");
//2) Enter field description to appear in the dialog box
var fieldDescription = Array("First Name", "Last Name");
//3) Enter dialog message
var alertMsg = "Please complete the following fields:n";
var l_Msg = alertMsg.length;
for (var i = 0; i < fieldRequired.length; i++)
{
var obj = formobj.elements[fieldRequired[i]];
if (obj)
{
switch(obj.type)
{
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "")
{
alertMsg += " - " + fieldDescription[i] + "n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1)
{
alertMsg += " - " + fieldDescription[i] + "n";
}
break;
case "text":
case "textarea":
if (obj.value == "" || obj.value == null)
{
alertMsg += " - " + fieldDescription[i] + "n";
}
break;
default:
if (obj.value == "" || obj.value == null)
{
alertMsg += " - " + fieldDescription[i] + "n";
}
}
}
}
if (alertMsg.length == l_Msg)
{
return true;
}
else
{
alert(alertMsg);
return false;
}
}
</script>
<form name="formcheck" onsubmit="return formCheck(this);">
First Name: <input type=text name="FirstName" size="25"><br>
Last Name: <input type=text name="LastName" size="25"><br>
<input type=submit value="Submit Form">
</form>
Script che consente di andare avanti solo con
l'accettazione delle condizioniCODICE<script>
var checkobj
function agreesubmit(el)
{
checkobj=el
if (document.all||document.getElementById)
{
for (i=0;i<checkobj.form.length;i++)
{ //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}
function defaultagree(el)
{
if (!document.all&&!document.getElementById)
{
if (window.checkobj&&checkobj.checked)
return true
else
{
alert("Please read/accept terms to submit form")
return false
}
}
}
</script>
<form name="agreeform" onSubmit="return defaultagree(this)">
<br>Qui va il resto del form, comprese le condizioni...<br><br>
<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">
<b>Ho letto ed accetto le condizioni</b><br>
<input type="Submit" value="Submit!" disabled>
</form>
<script>
document.forms.agreeform.agreecheck.checked=false
</script>
Verifica validità del numero di carta di
creditoCODICE<HTML><HEAD><TITLE>titolo</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT language=JavaScript>
// variabile per la verifica degli errori di inserimento
toterr=0
// funzione che verifica i dati inseriti
function verins() {
// variabile che permette di proseguire a dati inseriti correttamente
avanti=true
// variabile per il controllo del numero della carta di credito
num="0123456789"
// dichiara e azzera la matrice err che conterrà il numero di controllo finale
err=new Array()
for(n=0;n<=15;n++) {
err[n]=0
}
// confronta ogni carattere della variabile num con ogni carattere del campo
// "numero carta di credito". Se non è un numero, err non viene incrementata
// e non arriverà al totale di 144 errori, unico numero che corrisponde
// all'inserimento corretto, ovvero 16 numeri di cui 1 su 10 è esatto, ne
// rimangono 9 errati, quindi 16*9=144
for(a=0;a<=15;a++) {
for(b=0;b<=9;b++) {
if(document.form1.ccn.value.charAt(a)!=num.charAt(b)) {
err[a]++
}
}
}
// somma tutti gli errori memorizzati in err[]
for(t=0;t<err.length;t++) {
toterr+=err[t]
}
// rileva l'eventuale errore e interrompe la sottomissione dei dati
if(document.form1.ccn.value.length!=16 || toterr!=144) {
alert("Numero errato")
toterr=0
document.form1.ccn.value=""
document.form1.ccn.focus()
avanti=false
}
// controllo sulla data di scadenza in base al numero dei mesi e ad un limite
// minimo ed un massimo di anno
if(document.form1.ccm.value.length<1 || document.form1.ccm.value.length>2 ||
document.form1.ccm.value<1 || document.form1.ccm.value>12 ||
document.form1.cca.value.length<1 || document.form1.cca.value.length>4 ||
document.form1.cca.value<1999 || document.form1.cca.value>2004) {
alert("Data errata")
document.form1.ccm.value=""
document.form1.cca.value=""
if(!avanti) {
document.form1.ccn.focus()
}
else {
document.form1.ccm.focus()
}
avanti=false
}
if(avanti) {ok()}
}
// funzione che conferma l'inserimento corretto dei dati
function ok() {
alert("I dati sono stati inseriti correttamente")
document.form1.ccn.value=""
document.form1.ccm.value=""
document.form1.cca.value=""
document.form1.ccn.focus()
}
</SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY onload=document.form1.ccn.focus()>
<BR>
<FORM name=form1>
<H2>Verifica del numero di una carta di credito</H2><INPUT size=16
name=ccn> Inserisci il numero della carta di credito (senza
punteggiatura o spazi) <BR><BR><INPUT size=2 name=ccm> <INPUT size=4
name=cca> Inserisci il mese e l'anno di scadenza (formato mm-aaaa)
<BR><BR><INPUT onclick=verins() type=button value=verifica>
</FORM></BODY></HTML>
Grafici in javascript
>>ESEMPIO DI QUESTO SCRIPT
CON UN'IMMAGINE DA CUI SI CAPISCE LA FUNZIONE DEL SUDDETTO<<CODICE<SCRIPT LANGUAGE="JavaScript">
<!-- Hide JavaScript from Java-Impaired Browsers
function getHplot(){
n=new initArray(0,0,0,0,0,0)
v=new initArray(0,0,0,0,0,0)
rtitle=document.isnform.title.value;
stitle=document.isnform.stitle.value;
document.write('<TABLE BORDER=1 WIDTH=450><TR><TD '
+'COLSPAN=3 ALIGN=CENTER><B>Grafico orizzontale a colonne</'
+'B></TD></TR><TR><TD COLSPAN=3 ALIGN=CENTER><B>'
+rtitle+'</B><BR><I>'+stitle+'</I></TD></TR>');
v[0]=document.isnform.v1.value;
v[1]=document.isnform.v2.value;
v[2]=document.isnform.v3.value;
v[3]=document.isnform.v4.value;
v[4]=document.isnform.v5.value;
v[5]=document.isnform.v6.value;
n[9]=0;
n[6]=0;
n[7]=0;
for (var i=0;i<6;i++){
if (v[i].length>n[9]){
n[9]=v[i].length;
}
/* The next three lines are needed for visitors who
still live on the Win3.x platform. If none of your
visitors use older platforms,
n[i]=eval(v[i]);
may be substituted for these three lines. */
str=v[i]
StringToNumber();
n[i]=num; // eval(v[i]); may be substituted
if (n[i]<0){
n[i]=0;
}
n[6]+=n[i];
if (n[i]>n[7]){
n[7]=n[i];
}
}
n[10]=(n[9]+6)*8
n[8]=n[7]/(450-n[10]); // my divisor
document.write('<TR><TD><B>'+document.isnform.n1.value
+'</B></TD><TD><IMG SRC="java72a.gif" HEIGHT=10 WIDTH='
+(n[0]/n[8])+' BORDER=1></TD><TD>'+v[0]+'</TD></TR>'
+'<TR><TD><B>'+document.isnform.n2.value
+'</B></TD><TD><IMG SRC="java72b.gif" HEIGHT=10 WIDTH='+(n[1]/n[8])
+' BORDER=1></TD><TD>'+v[1]+'</TD></TR>'
+'<TR><TD><B>'+document.isnform.n3.value
+'</B></TD><TD><IMG SRC="java72c.gif" HEIGHT=10 WIDTH='+(n[2]/n[8])
+' BORDER=1></TD><TD>'+v[2]+'</TD></TR>'
+'<TR><TD><B>'+document.isnform.n4.value
+'</B></TD><TD><IMG SRC="java72d.gif" HEIGHT=10 WIDTH='+(n[3]/n[8])
+' BORDER=1></TD><TD>'+v[3]+'</TD></TR>'
+'<TR><TD><B>'+document.isnform.n5.value
+'</B></TD><TD><IMG SRC="java72e.gif" HEIGHT=10 WIDTH='+(n[4]/n[8])
+' BORDER=1></TD><TD>'+v[4]+'</TD></TR>'
+'<TR><TD><B>'+document.isnform.n6.value
+'</B></TD><TD><IMG SRC="java72a.gif" HEIGHT=10 WIDTH='+(n[5]/n[8])
+' BORDER=1></TD><TD>'+v[5]+'</TD></TR>');
document.write('<TR><TD COLSPAN=3><HR NOSHADE></TD></TR></TABLE>');
getVplot();
}
function getVplot(){
n[8]=n[7]/100;
document.write('<P><TABLE BORDER=0 WIDTH=450><TR><TD'
+' COLSPAN=6 ALIGN=CENTER><B>Grafico verticale a colonne</B></TD></TR>'
+'<TR><TD COLSPAN=6 ALIGN=CENTER><B>'
+rtitle+'</B><BR><I>'+stitle+'</I></TD></TR><TR>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72a.gif" HEIGHT='
+(n[0]/n[8])
+' WIDTH=50 BORDER=1></TD>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72b.gif" HEIGHT='
+(n[1]/n[8])+' WIDTH=50 BORDER=1></TD>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72c.gif" HEIGHT='
+(n[2]/n[8])+' WIDTH=50 BORDER=1></TD>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72d.gif" HEIGHT='
+(n[3]/n[8])+' WIDTH=50 BORDER=1></TD>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72e.gif" HEIGHT='
+(n[4]/n[8])+' WIDTH=50 BORDER=1></TD>'
+'<TD VALIGN=BOTTOM ALIGN=CENTER><IMG SRC="java72a.gif" HEIGHT='
+(n[5]/n[8])+' WIDTH=50 BORDER=1></TD></TR><TR>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n1.value+'</B></TD>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n2.value+'</B></TD>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n3.value+'</B></TD>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n4.value+'</B></TD>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n5.value+'</B></TD>'
+'<TD ALIGN=CENTER><B>'+document.isnform.n6.value+'</B></TD></TR>'
+'<TR><TD ALIGN=CENTER>'+v[0]+'</B></TD>'
+'<TD ALIGN=CENTER>'+v[1]+'</TD>'
+'<TD ALIGN=CENTER>'+v[2]+'</TD>'
+'<TD ALIGN=CENTER>'+v[3]+'</TD>'
+'<TD ALIGN=CENTER>'+v[4]+'</TD>'
+'<TD ALIGN=CENTER>'+v[5]+'</TD></TR><TR><TD COLSPAN=6'
+'><HR NOSHADE><P></TD></TR></TABLE>');
}
var pwr=new initArray(1,2,3,4);
pwr[0]=1;
pwr[1]=10;
pwr[2]=100;
pwr[3]=1000;
pwr[4]=10000;
pwr[5]=100000;
pwr[6]=1000000;
pwr[7]=10000000;
/* Add more to array - pwr[8]=100000000, etc. -
if strings longer than 8 are to be used. */
var ns="0123456789"
var cr="";
var str="";
/* Pass this function a string (named "str") and it will
return a number (named "num") Useful until all versions
of JavaScript on all platforms support string to numeric
conversions with predictability. */
function StringToNumber(){
num=0;
strl=str.length;
for (var j=strl-1;j>-1;j--){
cr=str.substring(j,j+1);
pos=ns.indexOf(cr);
num+=pos*pwr[strl-j-1];
}
}
function initArray() {
this.length=initArray.arguments.length;
for (var i=0;i<this.length;i++) {
this[i]=initArray.arguments[i];
}
}
// End Hiding -->
</SCRIPT>
Conta caratteri rimanenti in un form
>>ESEMPIO DI QUESTO
SCRIPT<<CODICE<head>
<title>Conta caratteri rimasti - Esempio JavaScript scaricato da HTML.it</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="it" />
<meta name="Robots" content="All" />
<meta name="Description" content="HTML.it - il sito italiano sul Web publishing" />
<meta name="Keywords" content="Ad ogni apertura di pagina questo script genera un
differente colore di sfondo." />
<meta name="Owner" content="HTML.it srl" />
<meta name="Author" content="HTML.it srl" />
<meta name="Copyright" content="HTML.it srl" />
<script type="text/javascript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Written by Steve - http://jsmadeeasy.com/ -->
<!--
function getObject(obj) {
var theObj;
if(document.all) {
if(typeof obj=="string") {
return document.all(obj);
} else {
return obj.style;
}
}
if(document.getElementById) {
if(typeof obj=="string") {
return document.getElementById(obj);
} else {
return obj.style;
}
}
return null;
}
//Contador de caracteres.
function Contar(entrada,salida,texto,caracteres) {
var entradaObj=getObject(entrada);
var salidaObj=getObject(salida);
var longitud=caracteres - entradaObj.value.length;
if(longitud <= 0) {
longitud=0;
texto='<span class="disable"> '+texto+' </span>';
entradaObj.value=entradaObj.value.substr(0,caracteres);
}
salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}
//-->
</script>
</head>
<body>
<h1>Conta caratteri rimasti</h1>
<form action="#" method="post">
<table align="center" class="0" border="0" cellspacing="1" cellpadding="5">
<tr>
<td align="right" class="1"><span class="options">Campo di testo</span></td>
<td class="2"><input type="TEXT" class="text" id="eBann" name="bannerURL"
maxlength="100" size="60" onkeyup="Contar('eBann','sBann','{CHAR} caratteri
rimanenti.',100);"><br>
<span id="sBann" class="minitext">100 caratteri rimanenti.</span></td>
</tr>
</table>
</form> <br />
<br />
<br />
<br />
Testo con effetto dissolvenzaCODICE<i>Posizionate il seguente codice tra i tag <HEAD> e </HEAD> nel vostro documento
HTML:</i>
<script language=Javascript>
function checkBrowserForVersion4(){
var x=navigator.appVersion;y=x.substring(0,4);if(y>=4)strobeEffect();}
var isNav=(navigator.appName.indexOf("Netscape")!=-1);
var colors=new Array("FFFFFF", "FFFFFF", "FFFFFF", "FFFFFF", "FFFFFF", "FFFFFF", "FFFFFF",
"F9F9F9", "F1F1F1", "E9E9E9", "E1E1E1", "D9D9D9", "D1D1D1", "C9C9C9", "C1C1C1", "B9B9B9",
"B1B1B1", "A9A9A9", "A1A1A1", "999999", "919191", "898989", "818181", "797979", "717171",
"696969", "616161", "595959", "515151", "494949", "414141", "393939", "313131", "292929",
"212121", "191919", "111111", "090909", "000000")
a=0,b=1
function strobeEffect(){
color=colors[a];aa="<font color="+color+">place your text here</font>"
if(isNav) {document.object1.document.write(aa);document.object1.document.close();}
else object1.innerHTML=aa
a+=b;if (a==38) b-=2;if (a==0) b+=2;xx=setTimeout("strobeEffect()",10);}
</script>
<i>Includete quindi quanto segue nel tag stesso<BODY>: </i>
<body onload="checkBrowserForVersion4()">
<i>
Infine, inserite questa stringa tra i tag <BODY> e </BODY> nella posizione appropriata:</i>
<div id="object1" style="position:absolute; visibility:show; left:25px; top:50px;
z-index:2"></div>
Potete posizionare il testo dove desiderate, modificando i valori degli attributi top e
left.
Un browser per le vostre immagini
ESEMPIOCODICEPer prima cosa, copiate questo script all'inizio della pagina, specificando nella
tabella images i nomi delle immagini ad alta risoluzione (my_image1.jpg, my_image2.jpg...) :
<SCRIPT LANGUAGE="JavaScript">
<!--
function previewPic(sel) {
document.previewpic.src = "" + sel.options[sel.selectedIndex].value;
}
function showPic(sel) {
images = new Array();
images[1] = "my_image1.jpg";
images[2] = "my_image2.jpg";
images[3] = "my_image3.jpg";
images[4] = "my_image4.jpg";
window.location.href = images[sel.selectedIndex+1];
}
// End -->
</script>
Posizionate quindi l'immagine iniziale e la forma associata, dove desiderate. Specificate
nella seguente porzione di script sia le immagini utilizzate per l'anteprima che il
rispettivo formato.
<center>
<form name=picform>
<select name=selbox size=1 onChange="previewPic(this)">
<option value="my_image1_small.jpg">Image 1
<option value="my_image2_small.jpg">Image 2
<option value="my_image3_small.jpg">Image 3
<option value="my_image4_small.jpg">Image 4
</select>
<p>
<img name="previewpic" src="my_image1_small.jpg" width=150 height=113 border=1>
<p>
<input type=button value="Enlarge" onclick="showPic(this.form.selbox)">
</form>
</center>
Caratteri minimi inseribili in un modulo
ESEMPIO:
http://www.massimo61.org/java
script/form/car_min_txt.htmlCODICE<script language=JavaScript>
<!-- Autore: Massimo Giari (webmaster@massimo61.org) -->
<!--
function controlla(){
var f = document.Mioform;
if (!f.accetto.checked){
alert("Seleziona Accetto: per continuare !");
return false;
}else{
alert("Hai selezionato Accetto: puoi continuare !");
}
}
//-->
</script>
</head>
<body>
<form name="Mioform" action="Tua_Azione" onSubmit="return controlla()">
Accetto: <input type="checkbox" value="0" name="accetto">
<input type="Submit" value="Continua">
</form>
<p><center>
<font face="Verdana" size="-2">Free JavaScripts da<br>
<a href="http://www.massimo61.org/">Free Web Upgrade</a></font>
</center><p>
Edited by SUPREMO_KING - 29/11/2009, 15:52. -
Arsene-Lupin.
User deleted
scsate o sn totalmente ignorante o alcuni non funzionano qualcuno mi darebbe una mano ?
ho letto ke ci sono quelle per webmaster e quelle per forum... alcune del secondo gruppo funzionano anche su forumfree ma altre tipo quella delle targhette non mi funzionano. -
Alessiov96.
User deleted
si anke a me non partono tutte! . -
SUPREMO KING™.
User deleted
CITAZIONE (Arsene-Lupin @ 24/2/2009, 13:46)scsate o sn totalmente ignorante o alcuni non funzionano qualcuno mi darebbe una mano ?
ho letto ke ci sono quelle per webmaster e quelle per forum... alcune del secondo gruppo funzionano anche su forumfree ma altre tipo quella delle targhette non mi funzionano
Mi pare sia già precisato nel primo topic che il secondo elenco contiene script che non si riferiscono ai forum del circuito...