Raccolta di JavaScript

« Older   Newer »
  Share  
erkillatore
view post Posted on 4/3/2010, 15:44




Chi volesse inserire altri script può postarli in questa discussione.

Link lampeggianti

CODICE
<!-- Prelevato nel Forum di Supporto forumlab.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>


Script anti-copiatura
Questo script disabilita il tasto destro del mouse


CODICE
<!-- Prelevato nel Forum di Supporto forumlab.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>


Aggiungi a preferiti

CODICE
<!-- Prelevato nel Forum di Supporto forumlab.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>


NOTA:questo codice funziona solo con internet explorer

Orologio

CODICE
<!-- Prelevato nel Forum di Supporto forumlab.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>


Data

CODICE
<!-- Prelevato nel Forum di Supporto forumlab.forumcommunity.net-->
<script type="text/javascript">today=new Date(); document.write("La data di oggi: ", today.getDate(),"/",today.getMonth()+1,"/",today.getFullYear())</script>


Messaggio di benvenuto in base all'ora

CODICE
<!-- 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.")
if (ora > 13 && ora <= 19)document.write ("<p>E' pomeriggio (non hai nient'altro da fare ?!), comunque benvenuto in questa pagina.")
if (ora > 19 && ora <= 24)document.write ("<p>E' sera (come non esci ?!), benvenuto lo stesso in questa pagina.")
if (ora >= 0 && ora <= 6)document.write ("<p>E' notte (che ci fai ancora sveglio !!), benvenuto (in coma :-)) in questa pagina.")</script>


Fusi orari

CODICE
<!-- Prelevato nel Forum di Supporto forumlab.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>



Calendario

CODICE
<!-- Prelevato nel Forum forumlab.forumcommunity.net-->
<script type="text/javascript">setCal();
function getTime(){var now=new Date(); var hour=now.getHours(); var minute=now.getMinutes(); now=null; var ampm=""; if(hour>=12){hour-=12; ampm="PM"} else ampm="AM"; hour=hour==0 ? 12 : hour; if(minute<10) minute="0"+minute; return hour+":"+minute+" "+ampm}
function leapYear(year){return year % 4==0 ? true : false}
function getDays(month,year){var x=new Array(31,(leapYear(year) ? 29 : 28),31,30,31,30,31,31,30,31,30,31); return x[month]}
function getMonthName(month){var y=new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"); return y[month]}
function setCal(){var now=new Date(); var year=now.getFullYear(); var month=now.getMonth(); var monthName=getMonthName(month); var date=now.getDate(); now=null; var firstdayInstance=new Date(year,month,1); var firstday=firstdayInstance.getDay(); firstdayInstance=null; var days=getDays(month,year); drawCal(firstday+1, days, date, monthName, year)}

function drawCal(firstday, lastDate, date, monthName, year) {
var topHeight=20 // height of the table's top cell
var border=4 // 3D height of table's border
var cellspacing=3 // width of table's border
var topColor="midnightblue" // color of table's top
var topSize="+1" // size of tables top font
var colWidth=30 // width of columns in table
var dayCellHeight=15 // height of cells containing days of the week
var dayColor="darkblue" // color of font representing week days
var cellHeight=20 // height of cells representing dates in the calendar
var todayColor="red" // color specifying today's date in the calendar
var timeColor="purple" // color of font representing current time
var text=""
text+='<table border='+border+' cellspacing='+cellspacing+'>' // table settings
text+='<th colspan=7 height='+topHeight+'>' // create table top cell
text+='<font face="verdana" color="'+topColor+'" size='+topSize+'>' // set font for table top
text+=monthName+' '+year
text+='</font>' // close table top's font settings
text+='</th>' // close top cell

var openCol='<td width='+colWidth+' height='+dayCellHeight+'>'; openCol+='<font face="verdana" color="'+dayColor+'">'; var closeCol='</font>'; var weekDay=new Array("Dom","Lun","Mar","Mer","Gio","Ven","Sab"); text+='<tr align="center" valign="center">'; for(var dayNum=0; dayNum<7; ++dayNum){text+=openCol+weekDay[dayNum]+closeCol} var digit=1; var curCell=1; for(var row=1; row<=Math.ceil((lastDate+firstday-1)/7); ++row){text+='<tr align="right" valign="top">'; for(var col=1; col<=7; ++col){if(digit>lastDate) break; if(curCell<firstday){text+='<td>'; curCell++} else{if(digit==date){text+='<td height='+cellHeight+'>'; text+='<b><font face="verdana" color="'+todayColor+'"></b>'; text+=digit; text+='</font><br>'; text+='<font face="verdana" color="'+timeColor+'" size="2">'; text+='</font>'} else text+='<td HEIGHT='+cellHeight+'><font face="verdana">'+digit+'</font>'; digit++}}} text+='</table>'; document.write(text)}</script>


Pagina a tutto schermo
CODICE
<!-- Prelevato nel Forum forumlab.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>



Stelle animate nello sfondo della pagina

CODICE
<!-- Prelevato nel Forum forumlab.forumcommunity.net-->
<body bgcolor="#000000"><script type="text/javascript">SmallStars = 20; LargeStars = 30; SmallYpos = new Array(); SmallXpos = new Array(); LargeYpos = new Array(); LargeXpos = new Array(); Smallspeed= new Array(); Largespeed= new Array(); ns=(document.layers)?1:0; if (ns){for (i = 0; i < SmallStars; i++){document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1'></LAYER>")}for (i = 0; i < LargeStars; i++){document.write("<LAYER NAME='ln"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2'></LAYER>")}}else{document.write('<div style="position:absolute; top:0px; left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < SmallStars; i++){document.write('<div id="si" style="position:absolute; top:0; left:0; width:1px; height:1px; background:#fffff0; font-size:1px"></div>')}document.write('</div>'); document.write('</div>'); document.write('<div style="position:absolute; top:0px; left:0px">'); document.write('<div style="position:relative">'); for (i = 0; i < LargeStars; i++) {document.write('<div id="li" style="position:absolute; top:0; left:0; width:2px; height:2px; background:#ffffff; font-size:2px"></div>')}document.write('</div>'); document.write('</div>')}WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight; WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth; for (i=0; i < SmallStars; i++) {SmallYpos[i] = Math.round(Math.random()*WinHeight); SmallXpos[i] = Math.round(Math.random()*WinWidth); Smallspeed[i]= Math.random()*1+1}for (i=0; i < LargeStars; i++) {LargeYpos[i] = Math.round(Math.random()*WinHeight); LargeXpos[i] = Math.round(Math.random()*WinWidth); Largespeed[i]= Math.random()*1+1}function fly(){var WinHeight=(document.layers)?window.innerHeight:window.document.body.clientHeight; var WinWidth=(document.layers)?window.innerWidth:window.document.body.clientWidth; var hscrll=(document.layers)?window.pageYOffset:document.body.scrollTop; var wscrll=(document.layers)?window.pageXOffset:document.body.scrollLeft; for (i=0; i < LargeStars; i++){LargeXpos[i]-=Largespeed[i]; if (LargeXpos[i] < -10){LargeXpos[i]=WinWidth; LargeYpos[i]=Math.round(Math.random()*WinHeight); Largespeed[i]=Math.random()*1+1}if (ns){document.layers['ln'+i].left=LargeXpos[i]; document.layers['ln'+i].top=LargeYpos[i]+hscrll}else{li[i].style.pixelLeft=LargeXpos[i]; li[i].style.pixelTop=LargeYpos[i]+hscrll}}for (i=0; i < SmallStars; i++){SmallXpos[i]-=Smallspeed[i]; if (SmallXpos[i] < -10){SmallXpos[i]=WinWidth; SmallYpos[i]=Math.round(Math.random()*WinHeight); Smallspeed[i]=Math.random()*5+1}if (ns){document.layers['sn'+i].left=SmallXpos[i]; document.layers['sn'+i].top=SmallYpos[i]+hscrll}else{si[i].style.pixelLeft=SmallXpos[i]; si[i].style.pixelTop=SmallYpos[i]+hscrll}}setTimeout('fly()',10)}</script></body>
<body="fly()"></body>


Edited by erkillatore - 4/3/2010, 20:26
 
Top
0 replies since 4/3/2010, 15:44   96 views
  Share