Java Script - On My Radar Screen

Search
Go to content

Main menu:

Java Script

 
 

Marquee Generator

.

.

.

.

.

 

Image Rollover Script

Copy the following code into your <HEAD></HEAD> tags.

Copy the following code between the <BODY></BODY> tags of your html page.

 

<script language="Javascript">
<!--
//Slide Show script (this notice must stay intact)
//For this and more scripts
//visit java-scripts.net or http://wsabstract.com

if (document.images)
    button1 = new Image
    button2 = new Image

    button1.src = 'img1.gif'
    button2.src = 'img2.gif'

//-->
</script>

<a href="http://java-scripts.net" onmouseover="document.rollover.src=button2.src" onmouseout="document.rollover.src=button1.src"><img src="img1.gif" border=0 name="rollover"></a>

 

Random Image Script

Copy the following code between the <BODY></BODY> tags of your html page.

 

<script language="JavaScript">
<!--
/*
Random Image Link Script
By Website Abstraction (http://www.wsabstract.com)
and Java-scripts.net (http://www.java-scripts.net)
*/

function random_imglink()
 var myimages=new Array()
 //specify random images below. You can have as many as you wish
 myimages[1]="img1.gif"
 myimages[2]="img2.gif"
 myimages[3]="img3.gif"

 //specify corresponding links below
 var imagelinks=new Array()
 imagelinks[1]="http://www.wsabstract.com"
 imagelinks[2]="http://www.dynamicdrive.com"
 imagelinks[3]="http://www.java-scripts.net"

 var ry=Math.floor(Math.random()*myimages.length)

 if (ry==0)
    ry=1
    document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')


 random_imglink()
//-->
</script>

Automatically Changing Slide Show Script

Copy the following code into your <HEAD></HEAD> tags.

Copy the following code between the <BODY></BODY> tags of your html page.

 

<script language="JavaScript1.1">
<!--
/*
JavaScript Image slideshow:
By Website Abstraction (www.wsabstract.com)
and Java-scripts.net (www.java-scripts.net)
*/

var slideimages=new Array()
var slidelinks=new Array()

function slideshowimages()
 for (i=0;i<slideshowimages.arguments.length;i++)
 slideimages[i]=new Image()
 slideimages[i].src=slideshowimages.arguments[i]
 


function slideshowlinks()
 for (i=0;i<slideshowlinks.arguments.length;i++)
 slidelinks[i]=slideshowlinks.arguments[i]


function gotoshow()
 if (!window.winslide||winslide.closed)
   winslide=window.open(slidelinks[whichlink])
 else
   winslide.location=slidelinks[whichlink]
   winslide.focus()

//-->
</script>

<a href="javascript:gotoshow()"><img src="img1.gif" name="slide" border=0></a>

<script>
<!--
//configure the paths of the images, plus corresponding target links
slideshowimages("img1.gif", "img2.gif", "img3.gif")
slideshowlinks("http://wsabstract.com", "http://dynamicdrive.com", "http://java-scripts.net")

//configure the speed of the slideshow, in miliseconds
var slideshowspeed=2000
var whichlink=0
var whichimage=0

function slideit()
 if (!document.images)
   return
   document.images.slide.src=slideimages[whichimage].src
   whichlink=whichimage

 if (whichimage<slideimages.length-1)
   whichimage++
 else
   whichimage=0
   setTimeout("slideit()",slideshowspeed)

slideit()
//-->
</script>

Javascript Forms > Random Quote in Form Box

Copy the following code between the <BODY></BODY> tags of your html page.

 

<form name="random"><input type="text" name="random" size=75 value=""></form>
<SCRIPT LANGUAGE="JavaScript">


function getQuote()
// create array of quotes
var ar = new Array(20)
ar[0] = "A man who carries a cat by the tail learns something he can learn in no other way."
ar[1] = "All that I know I learned after I was thirty."
ar[2] = "Every moment is an experience."
ar[3] = "Excellence is not a skill. It is an attitude."
ar[4] = "Experience is a great teacher."
ar[5] = "Experience is one thing you can't get for nothing."


var now = new Date()
var sec = now.getSeconds()
document.random.random.value="Murphy's Law: " + ar[sec % 5]

getQuote()
//-->
</SCRIPT>

Slide Show Script

Copy the following code between the <BODY></BODY> tags of your html page.

 

<p align="center"><img name="myPicture" src="img1.gif" width="100" height="57">

<script language="JavaScript">
<!--
//Slide Show script (this notice must stay intact)
//For this and more scripts
//visit java-scripts.net or http://wsabstract.com

var myPix = new Array("img1.gif","img2.gif","img3.gif")
var thisPic = 0

function doPrevious()
   if (document.images && thisPic > 0)
       thisPic--
       document.myPicture.src=myPix[thisPic]
   


function doNext()
   if (document.images && thisPic < 2)
       thisPic++
       document.myPicture.src=myPix[thisPic]
   

// -->
</script>

<br><small><font face="Verdana"><a href="javascript:doPrevious()">Previous</a><font color="#FFFFFF">-</font> <a href="javascript:doNext()">Next</a></font></small>

Image slideshows

Simply copy the below into the <BODY> of your page:

 

<script language="javascript">

/*
Random image slideshow- By Tyler Clarke (tyler@ihatecoffee.com)
For this script and more, visit http://www.javascriptkit.com
*/

var delay=1000 //set delay in miliseconds
var curindex=0

var randomimages=new Array()

randomimages[0]="1.jpg"
randomimages[1]="5.jpg"
randomimages[2]="2.jpg"
randomimages[3]="4.jpg"
randomimages[4]="3.jpg"
randomimages[5]="6.jpg"

var preload=new Array()

for (n=0;n<randomimages.length;n++)

preload[n]=new Image()
preload[n].src=randomimages[n]


document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]+'">')

function rotateimage()


if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length))))
curindex=curindex==0? 1 : curindex-1

else
curindex=tempindex

document.images.defaultimage.src=randomimages[curindex]


setInterval("rotateimage()",delay)

</script>

<p align="center">This free script provided by<br />
<a href="http://javascriptkit.com">JavaScript
Kit</a></p>

Random Quote

Copy the following code between the <BODY></BODY> tags of your html page.

 

<SCRIPT>
/*
Script obtained from Wsabstract.com
For this script and more
Visit Java-Scripts.net or Wsabstract.com
*/

quote0= "Life is like a box of chocolates.";
quote1= "Java-Scripts.net is like a box of coco pops. ";
quote2= "I have no idea what I am saying. ";

var ran_unrounded=Math.random()*2;
var ran_number=Math.round(ran_unrounded);

document.write(eval("quote"+ran_number));
</SCRIPT>

Game of Chance

Copy the following code into your <HEAD></HEAD> tags.

 

<script language="javascript">

//
//This Script belongs to Blade: Aaron Connelly
//It may be used for nonComercial profit
//


function rollDice()

DiceOne=Math.round(Math.random() * 5) + 1
result1=document.random.dice.value=DiceOne
DiceTwo=Math.round(Math.random() * 5) + 1
result2=document.random.dice2.value=DiceTwo

equal=document.random.dice3.value=result1 + result2

if(document.random.dice3.value=="12")
alert("you WON!!!!!!   with the LUCKY roll of    12    ")

if(document.random.dice3.value=="2")
alert("you got SNAKE EYES    you lose. Sorry.")

if(document.random.dice3.value=="7")
alert("you WON!!!!!  with the LUCKY roll of     7     ")


</script>

Javascript Calendars > Select A Month

Copy the following code into your <HEAD></HEAD> tags.

 

<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
function setToday()
var now   = new Date();
var day   = now.getDate();
var month = now.getMonth();
var year  = now.getYear();
if (year < 2000)    // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
this.focusDay = day;
document.calControl.month.selectedIndex = month;
document.calControl.year.value = year;
displayCalendar(month, year);

function isFourDigitYear(year)
if (year.length != 4)
alert ("Sorry, the year must be four-digits in length.");
document.calControl.year.select();
document.calControl.year.focus();
else  return true;

function selectDate()
var year  = document.calControl.year.value;
if (isFourDigitYear(year))
var day   = 0;
var month = document.calControl.month.selectedIndex;
displayCalendar(month, year);
   


function setPreviousYear()
var year  = document.calControl.year.value;
if (isFourDigitYear(year))
var day   = 0;
var month = document.calControl.month.selectedIndex;
year--;
document.calControl.year.value = year;
displayCalendar(month, year);
  

function setPreviousMonth()
var year  = document.calControl.year.value;
if (isFourDigitYear(year))
var day   = 0;
var month = document.calControl.month.selectedIndex;
if (month == 0)
month = 11;
if (year > 1000)
year--;
document.calControl.year.value = year;

else  month--;
document.calControl.month.selectedIndex = month;
displayCalendar(month, year);
  

function setNextMonth()
var year  = document.calControl.year.value;
if (isFourDigitYear(year))
var day   = 0;
var month = document.calControl.month.selectedIndex;
if (month == 11)
month = 0;
year++;
document.calControl.year.value = year;
else  month++;
document.calControl.month.selectedIndex = month;
displayCalendar(month, year);
  

function setNextYear()
var year = document.calControl.year.value;
if (isFourDigitYear(year))
var day = 0;
var month = document.calControl.month.selectedIndex;
year++;
document.calControl.year.value = year;
displayCalendar(month, year);
  

function displayCalendar(month, year)        
month = parseInt(month);
year = parseInt(year);
var i = 0;
var days = getDaysInMonth(month+1,year);
var firstOfMonth = new Date (year, month, 1);
var startingPos = firstOfMonth.getDay();
days += startingPos;
document.calButtons.calPage.value  =   " Su Mo Tu We Th Fr Sa";
document.calButtons.calPage.value += "--------------------";
for (i = 0; i < startingPos; i++)
if ( i%7 == 0 ) document.calButtons.calPage.value += "";
document.calButtons.calPage.value += "   ";

for (i = startingPos; i < days; i++)
if ( i%7 == 0 ) document.calButtons.calPage.value += "";
if (i-startingPos+1 < 10)
document.calButtons.calPage.value += "0";
document.calButtons.calPage.value += i-startingPos+1;
document.calButtons.calPage.value += " ";

for (i=days; i<42; i++)  
if ( i%7 == 0 ) document.calButtons.calPage.value += "";
document.calButtons.calPage.value += "   ";

document.calControl.Go.focus();

function getDaysInMonth(month,year)  
var days;
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;
else if (month==4 || month==6 || month==9 || month==11) days=30;
else if (month==2)  
if (isLeapYear(year))  days=29;
else  days=28;

return (days);

function isLeapYear (Year)
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0))
return (true);
else  return (false);

// End -->
</SCRIPT>

 
Back to content | Back to main menu