ManyCodes.com – codes & scripts Get free programming codes and tutorials!

29Jul/090

How to show the various time zones of the world on your website

Here is how you can show the various time zones of the world on your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<table border="0" width="200" cellspacing="0" cellpadding="3">
<form name="where">
 <tr>
 <td width="100%">
<select name="city" size="1" onchange="updateclock(this);">
<option value="" selected>Local time</option>
<option value="0">London GMT</option>
<option value="1">Rome</option>
<option value="7">Bangkok</option>
<option value="8">Hong Kong</option>
<option value="9">Tokyo</option>
<option value="10">Sydney</option>
<option value="12">Fiji</option>
<option value="-10">Hawaii</option>
<option value="-8">San Francisco</option>
<option value="-5">New York</option>
<option value="-3">Buenos Aires</option>
</select>

</td>
 </tr>
 <tr>
 <td width="100%">
<script language="JavaScript">

/*
Drop Down World Clock- By Learn iran (http://www.webloger.5u.com)
Portions of code by Kurt @ http://www.webloger.5u.com/
This credit notice must stay intact
*/

if (document.all||document.getElementById)
document.write('<span id="worldclock" style="font:bold 16px Arial;"></span><br>')

zone=0;
isitlocal=true;
ampm='';

function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}

function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?"PM":"AM";
statusampm = ampm.toLowerCase();

hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2="0"+hr2

var finaltime=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;
if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById("worldclock").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}


setTimeout('WorldClock()',1000);
}

window.onload=WorldClock
//-->
</script>

<!--Place holder for NS4 only-->
<ilayer id="worldclockns" width=100% height=35><layer id="worldclockns2" width=100% height=35 left=0 top=0 style="font:bold 16px Arial;"></layer></ilayer>

</td>
</form>
 </tr>
</table>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
29Jul/090

How to redirect to another webpage when a visitor visits your website

Here is how you can redirect to another webpage when a visitor visits your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<p><!--webbot bot="HTMLMarkup" startspan --><form name="redirect">
<center>
<font face="Arial"><b>You will be redirected to the script in<br><br>
<form>
<input type="text" size="3" name="redirect2">
</form>
seconds</b></font>
</center>

<script>
<!--

var targetURL="http://www.javakhafan.7p.com"
var countdownfrom=5


var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}

countredirect()
//-->
</script>
<!--webbot bot="HTMLMarkup" endspan --></p>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
29Jul/090

How to automatically maximize the browser window when a visitor accesses your website

Here is how you can automatically maximize the browser window when a visitor accesses your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<!-- START OF Window Auto Maximize DHTML -->

<!-- SUMMARY BRIEF

 This code will automatically maximize the
 browser window when the page is loaded.

-->

<!-- Put this code inside of your <HEAD> tag. -->

<script language="JavaScript1.2">
<!--

top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}

//-->
</script>

<!-- END OF Window Auto Maximize DHTML -->
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
29Jul/090

How to move/shake the internet explorer window when a visitor accesses your website

Here is how you can move/shake the internet explorer window when a visitor accesses your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<!-- START CODE Powered javascript code by WWW.javakhafan.7p.COM-->

<meta http-equiv="Content-Language" content="en-us">
<SCRIPT language=JavaScript>
<!-- Begin
function shake(n) {
if (parent.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {

parent.moveBy(-i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,-i);
parent.moveBy(i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,i);
 }
 }
 }

}
//  End -->

<!--
shake(1);
//-->
 </SCRIPT>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
29Jul/090

How to show an alert by click (msg box) on your website

Here is how you can show an alert by click (msg box) on your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com --><!-- Start of Message Alert -->
<!-- Use this button in a form to pop-up a message when the user clicks it -->
<form>
<input type="button" value="message" onClick="alert('YOUR MESSAGE GOES HERE'); return true">
</form>
<!-- End of Message Alert -->
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
29Jul/091

How to change status bar when moving mouse on picture on your website

Here is how you can change status bar when moving mouse on picture on your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
!-- This displays 'Your Message Here' in the status bar when the mouse -->
<!--    pointer is over the 'Put Image Here' image -->

<CENTER>
<A HREF="URL"  onMouseOver="window.status='Your Message Here'; return true"
onMouseOut="window.status=''">
<P><IMG SRC="Put Image Here"></A>
</CENTER>

<!-- This displays 'Your Message Here' in the status bar when the mouse -->
<!--    pointer is over the 'Put Image Here' image -->

<CENTER>
<A HREF="URL"  onMouseOver="window.status='Your Message Here'; return true"
onMouseOut="window.status=''">
<P><IMG SRC="Put Image Here"></A>
</CENTER>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
28Jul/090

How to have a opening popup with your website

Here is how to have a opening popup with your website.

Put the code below within your site's <head> </head> tags. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->

<!--   DESCRIPTION:  This will make a small Navigation Window in which you can place links to different pages.

 INSTRUCTIONS:  Place this script in the HEAD tags of
your webpage.

 FUNCTIONALITY:  Works in both Netscape & IE.
-->

<SCRIPT LANGUAGE="JavaScript">

//Modified by CoffeeCup Software
//This code is Copyright (c) 1997 CoffeeCup Software
//all rights reserved. License is granted to a single user to
//reuse this code on a personal or business Web Site.

<!--

coffeeWin=window.open("","coffeeWin","toolbar=no,width=200,height=250,directories=no,menubar=no,SCROLLBARS=no");

coffeeWin.document.write("<HTML>");
coffeeWin.document.write("<HEAD>");

coffeeWin.document.write("</HEAD>");

coffeeWin.document.write("<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#0000FF>")

coffeeWin.document.write("<CENTER>")

coffeeWin.document.write("<FONT FACE=VERDANA,ARIAL SIZE=2>");

coffeeWin.document.write("<B>");

coffeeWin.document.write("<FONT SIZE=3>Navigation Window</FONT>");

coffeeWin.document.write("<BR><HR WIDTH=180><BR><P>");

coffeeWin.document.write("<A HREF=http://www.webloger.5u.com TARGET=MAIN>Webloger Website</A>");

coffeeWin.document.write("<P>");

coffeeWin.document.write("<A HREF=http://www.microsoft.com TARGET=MAIN>Microsoft</A>");

coffeeWin.document.write("<P>");

coffeeWin.document.write("<A HREF=http://www.netscape.com TARGET=MAIN>Netscape</A>");

coffeeWin.document.write("<P>");

coffeeWin.document.write("<A HREF=http://www.infoseek.com TARGET=MAIN>InfoSeek</A>");

coffeeWin.document.write("<P>");

coffeeWin.document.write("</B>");

coffeeWin.document.write("</FONT>");

coffeeWin.document.write("</BODY>");

coffeeWin.document.write("</HTML>");

//-->
</SCRIPT>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
28Jul/090

How to have a slide show showing pictures on your website

Here is how you can have a slide show showing pictures on your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<!-- Drop Down Image Preview


 1.  Copy the coding into the HEAD of your HTML document
 2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
function CoffeePreview(sel) {
document.CoffeePreview.src = "" + sel.options[sel.selectedIndex].value;
}
function CoffeeShow(sel) {
images = new Array();
images[1] = "1.jpg";
images[2] = "2.jpg";
images[3] = "3.jpg";
images[4] = "4.jpg";
images[5] = "5.jpg";
images[6] = "6.jpg";
window.location.href = images[sel.selectedIndex+1];
}
//  End -->
</script>
</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<center>
<form name=previewselect>
<select name=selbox size=1 onChange="CoffeePreview(this)">
<option value="1-small.jpg">Image #1
<option value="2-small.jpg">Image #2
<option value="3-small.jpg">Image #3
<option value="4-small.jpg">Image #4
<option value="5-small.jpg">Image #5
<option value="6-small.jpg">Image #6
</select>
<p>
<img name="preview" src="1-small.jpg" width=150 height=113 border=1>
<p>
<input type=button value="view Image" onclick="CoffeeShow(this.form.selbox)">
</form>
</center>

<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
28Jul/090

How to have your visitor add your website to his web browser bookmarks with just a click

Here is how you can have your visitor add your website to his web browser bookmarks with just a click.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->
<!-- Start of Add to Favorites IE -->
<!-- Put this script anywhere in your webpage and when a visitor goes
 to your webpage using Internet Explorer, they only need to
 click on the link to add your webpage to their FAVORITES
 folder.  Netscape users will simply get a reminder to press
 CTRL-D to bookmark.
-->

<SCRIPT LANGUAGE="JavaScript">
<!--
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {

var url="http://www.webloger.5u.com";
var title="Webloger - Web Authoring Tools";

document.write('<A HREF="javascript:window.ext');
document.write('ernal.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Add our site to your favorites!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Add our site to your favorites!</a>');
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += "  (CTRL-D)";
document.write(msg);
}

// -->
</script>
<!-- End of Add to Favorites IE -->

<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>
28Jul/090

How to have date and time following mouse in your website

Here is how you can have date and time following mouse in your website.

Put the code below within your site's source code. If you dont know how to implement this code into your site, please goto how to implement the code to your website

Code:

<!-- this script is from www.manycodes.com -->

<span lang="en-us"><font color="#FFFFFF"><b>
<font size="5" color="#FFFFFF">
<a href="http://www.javakhafan.9f.com.com">http://www.javakhafan.9f.com.com</a></font></b></font></span>-->

<SCRIPT language=JavaScript>

dCol='cc0099';//date colour.

fCol='ff99cc';//face colour.

sCol='cc99ff';//seconds colour.

mCol='008000';//minutes colour.

hCol='000080';//hours colour.

ClockHeight=40;

ClockWidth=40;

ClockFromMouseY=0;

ClockFromMouseX=100;

//Alter nothing below! Alignments will be lost!

d=new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY");

m=new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");

date=new Date();

day=date.getDate();

year=date.getYear();

if (year < 2000) year=year+1900;

TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;

D=TodaysDate.split('');

H='ooo';

H=H.split('');

M='oooo';

M=M.split('');

S='.....';

S=S.split('');

Face='1 2 3 4 5 6 7 8 9 10 11 12';

font='tohoma';

size=1;

speed=0.6;

ns=(document.layers);

ie=(document.all);

Face=Face.split(' ');

n=Face.length;

a=size*10;

ymouse=0;

xmouse=0;

scrll=0;

props="<font face="+font+" size="+size+" color="+fCol+"><B>";

props2="<font face="+font+" size="+size+" color="+dCol+"><B>";

Split=360/n;

Dsplit=360/D.length;

HandHeight=ClockHeight/4.5

HandWidth=ClockWidth/4.5

HandY=-7;

HandX=-2.5;

scrll=0;

step=0.06;

currStep=0;

y=new Array();x=new Array();Y=new Array();X=new Array();

for (i=0; i < n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}

Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();

for (i=0; i < D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0}

if (ns){

for (i=0; i < D.length; i++)

document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props2+D[i]+'</font></center></layer>');

for (i=0; i < n; i++)

document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face[i]+'</font></center></layer>');

for (i=0; i < S.length; i++)

document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>');

for (i=0; i < M.length; i++)

document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>');

for (i=0; i < H.length; i++)

document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>');

}

if (ie){

document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < D.length; i++)

document.write('<div id="ieDate" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props2+D[i]+'</B></font></div>');

document.write('</div></div>');

document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < n; i++)

document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props+Face[i]+'</B></font></div>');

document.write('</div></div>');

document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < H.length; i++)

document.write('<div id="ieHours" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+'</div>');

document.write('</div></div>');

document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < M.length; i++)

document.write('<div id="ieMinutes" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+'</div>');

document.write('</div></div>')

document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < S.length; i++)

document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+'</div>');

document.write('</div></div>')

}

(ns)?window.captureEvents(Event.MOUSEMOVE):0;

function Mouse(evnt){

ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY;

xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;

}

(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;

function ClockAndAssign(){

time = new Date ();

secs = time.getSeconds();

sec = -1.57 + Math.PI * secs/30;

mins = time.getMinutes();

min = -1.57 + Math.PI * mins/30;

hr = time.getHours();

hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;

if (ie){

Od.style.top=window.document.body.scrollTop;

Of.style.top=window.document.body.scrollTop;

Oh.style.top=window.document.body.scrollTop;

Om.style.top=window.document.body.scrollTop;

Os.style.top=window.document.body.scrollTop;

}

for (i=0; i < n; i++){

 var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style;

 F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;

 F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);

 }

for (i=0; i < H.length; i++){

 var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style;

 HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;

 HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs);

 }

for (i=0; i < M.length; i++){

 var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;

 ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;

 ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);

 }

for (i=0; i < S.length; i++){

 var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style;

 SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;

 SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec);

 }

for (i=0; i < D.length; i++){

 var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style;

 DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll;

 DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180);

 }

currStep-=step;

}

function Delay(){

scrll=(ns)?window.pageYOffset:0;

Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed);

Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed);

for (i=1; i < D.length; i++){

Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed);

Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed);

}

y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);

x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);

for (i=1; i < n; i++){

y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);

x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);

}

ClockAndAssign();

setTimeout('Delay()',20);

}

if (ns||ie)window.onload=Delay;

 </SCRIPT>
<font face="Tahoma"><a target="_blank" href="http://www.manycodes.com/category/java/javascript-codes/"><span style="font-size: 8pt; text-decoration: none">JavaScript Free Code</span></a></font>