Image Viewer/Lightbox Javascript

http://www.huddletogether.com/projects/lightbox/

http://highslide.com/

Free Web Hosting Service

www.webexploring.com or www.twohosting.com

Our free hosting platform uses the powerful Vista Panel which includes the following features:

250 MB disk space

Vista Panel

Web mail

6 GB Monthly transfer

PHP Flags manager

POP email accounts

3 MySQL databases

Automatic installer (29 scripts)

Password protected folders

5 Add-on domains

FTP account

Php MyAdmin

5 Sub domains

File manager (browser upload)

Clustered servers

click here to see all our features and to find out more information

click here to sign up for free hosting

Source: www.webexploring.com

JavaScript example for timer

<html>
<head>
<script type=”text/javascript”>
var i=0;
function addnum()
{
//document.write(i + ‘<br/>’ );
document.getElementById(‘txt’).innerHTML=”Second: ” + i;
i++;
window.setTimeout(‘addnum()’ ,1000);
}

var mydate1 = new Date();
var timerFlag = 0;
mydate1.setMinutes(0,0,0);
function timer()
{

m = mydate1.getMinutes();
s = mydate1.getSeconds();
ms = mydate1.getMilliseconds();
ms1 = ms/10;
if (m<10) m = ’0′+m;
if (s<10) s = ’0′+s;
if (ms1<10) ms1 = ’0′+ms1;

document.getElementById(‘txt1′).innerHTML=m + “:” + s + “:” + ms1;
if (timerFlag==0) return;

mydate1.setMilliseconds(mydate1.getMilliseconds()+10);
window.setTimeout(“timer()”,1)

}
function startTimer()
{
timerFlag = 1;
document.getElementById(‘timerFlag’).innerHTML=”timerFlag: ” + timerFlag;
timer();
}

function stopTimer()
{
timerFlag = 0;
document.getElementById(‘timerFlag’).innerHTML=”timerFlag: ” + timerFlag;
//timer();
}

function resetTimer()
{
timerFlag = 0;
document.getElementById(‘timerFlag’).innerHTML=”timerFlag: ” + timerFlag;
mydate1.setMinutes(0,0,0);
timer();
}

</script>

</head>

<body>

<div id=”txt”>
<script type=”text/javascript”>
addnum();
</script>
</div>

<br />
<input type=”button” value=”Start Timer” onclick=”startTimer()”/>
<input type=”button” value=”Stop Timer” onclick=”stopTimer()”/>
<input type=”button” value=”Stop Timer” onclick=”resetTimer()”/>
<br />
<div id=”txt1″>
<!–
<script type=”text/javascript”>
timer()
</script>
–>
</div>

<div id=’timerFlag’>
<script type=”text/javascript”>
resetTimer()
</script>
</div>

</body>
</html>

Basic JavaScript Exmpale

<html>
<head>
<script type=”text/javascript”>
function message()
{
 alert(“This alert box was called with the onload event”);
}

function show_alert()
{
 alert(“This is an alert box”);
}

function show_confirm()
{
var r=confirm(“Press a button”);
if (r==true)
 {
 alert(“You pressed OK”);
 }
else
 {
 alert(“You pressed Cancel”);
 }
}

function show_prompt()
{
var name=prompt(“Please enter your name”,”Harry Potter”);
if (name!=null && name!=””)
 {
 document.write(“Hello ” + name + “! How are you today?”);
 }
}

function product(a,b)
{
return a*b;
}
</script>

<!– try…catch… statement –>
<script type=”text/javascript”>
var txt=””;
function try_message()
{
try
  {
  adddlert(“Welcome guest!”);
  }
catch(err)
  {
  txt=”There was an error on this page.\n\n”;
  txt+=”Error description: ” + err.description + “\n\n”;
  txt+=”Click OK to continue.\n\n”;
  alert(txt);
 if(!confirm(txt))
 {
 document.location.href=”http://www.w3schools.com/“;
 }
  }
}

function throw_catch()
{
var x=prompt(“Enter a number between 0 and 10:”,””);
try
  {
  if(x>10)
    {
    throw “Err1″;
    }
  else if(x<0)
    {
    throw “Err2″;
    }
  else if(isNaN(x))
    {
    throw “Err3″;
    }
  }
catch(er)
  {
  if(er==”Err1″)
    {
    alert(“Error! The value is too high”);
    }
  if(er==”Err2″)
    {
    alert(“Error! The value is too low”);
    }
  if(er==”Err3″)
    {
    alert(“Error! The value is not a number”);
    }
  }
}
</script>
</head>

<!– <body onload=”message()”> –>

<body>
<!–
<script type=”text/javascript”>
document.write(“<h1>Hello World</h1>”);
</script>
–>

<script type=”text/javascript”>
/*
The code below will write
one heading and two paragraphs
*/
document.write(“<h1>This is a heading</h1>”); //write a heading
document.write(“<p>This is a paragraph</p>”);
document.write(“<p>This is another paragraph.</p>”);
</script>

<script type=”text/javascript”>
var x=5;
var carname=”Volvo”;
y=5;
//carname=”Volvo”
z=x+y;
document.write(z);
document.write(“<br/>”)
txt1 = “What a very”;
txt2 = “nice day”;
txt = txt1+” “+txt2;
document.write(txt);

//add string to number, result is string
z+=’1′;
z=’<br/>’+z;
document.write(z);

document.write(‘<br/>’+’number==string: ‘);
document.write(1==’1′);
document.write(‘<br/>’+’number===string: ‘);
document.write(1===’1′);

//if statement
document.write(‘<br/>’);
age = 16
if(age<18) document.write(“too yong”)
</script>

<br/>
<script type=”text/javascript”>
//if … else if … else … statement
var d = new Date();
var time=d.getHours();

if (time<10)
 document.write(“Current time is “+d+”. ” + “<b>Good morning</b>”);  
else if(time>10 && time<16)
 document.write(“Current time is “+d+”. ” + “<b>Good day</b>”);
else
 document.write(“Current time is “+d+”. ” + “<b>Hello World</b>”);
</script>

<br/>
<script type=”text/javascript”>
//switch statement
document.write(‘<br/>’);
var d = new Date();
theDay = d.getDay();
switch(theDay)
{
case 5: document.write(“Friday”);break;
case 6: document.write(“Saturday”);break;
case 0: document.write(“Sunday”); break;
default: document.write(“I’m looking forward to this weekend!”);

}
</script>

<br/>
<!–alert box–>
<input type=”button” onclick=”show_alert()” value=”Show alert box” />
<button onclick=”show_alert()”>Show alert box</button>

<!–confirm box–>
<input type=”button” onclick=”show_confirm()” value=”Show confirm box” />

<!–Prompt box–>
<input type=”button” onclick=”show_prompt()” value=”Show prompt box” />

<script type=”text/javascript”>
//call a function
document.write(‘<br/>’+”product(3,4)=”+product(3,4));
</script>
<!–for loop–>
<br/>
<script type=”text/javascript”>
var i=0;
for (i=0;i<=10;i++)
{
 if (i==5) continue;
 if (i==9) break;
 document.write(“The number is ” + i);
 document.write(“<br/>”);

}
</script>

<br/>
<!–while loop–>
<script type=”text/javascript”>
var i=0;
while (i<=5)
 {
 document.write(“The number is ” + i);
 document.write(“<br/>”);
 i++;
 }
</script>

<!– for … in … loop –>
<br />
<script type=”text/javascript”>
var x;
var mycars =  new Array();
mycars[0]=’Saab’;
mycars[1]=”Volvo”;
mycars[2]=”BMW”;

for (x in mycars)
 {
 document.write(mycars[x] + “<br/>”);
 }
</script>

<br />
<!–onChange–>
<input type=”text” size=”30″ id=”email” onchange=”checkEmail()”>

<!–onSubmit–>
<form method=”post” action=”xxx.htm” onsubmit=”return checkForm()”>

<br />

<a href=”http://www.w3schools.com” onmouseover=”alert(‘an onMouseOver event’);return false”><img src=”http://www.w3schools.com/images/icon_green_sd.gif” alt=”W3Schools” /></a>

<br/>
<input type=”button” value=”View message” onclick=”try_message()” />

<!–Try throw catch –>
<input type=”button” onclick=”throw_catch()” value=”Show try_throw_catch” />

<br/>
<!– special text, use ‘\’ –>
<script type=”text/javascript”>
var txt=”We are the so-called \”Vikings\” from the north.”;
document.write(txt);
document.write (“You \& I are singing!”);
</script>

<script type=”text/javascript”>
var txt=”how are you?”;
document.write(‘<br/>’+”txt.length = ” + txt.length);
document.write(txt.toUpperCase());
document.write(“<br />”);
document.write(txt.indexOf(“a”) + “<br />”);
document.write(txt.indexOf(“ARE”) + “<br />”);
document.write(txt.indexOf(“are”));

document.write(“<br />”);
var str=”Visit Microsoft!”;
document.write(str.replace(“Microsoft”,”W3Schools”));

document.write(“<br />”);
var str=”Hello world!”;
document.write(str.match(“world”) + “<br />”);
document.write(str.match(“World”) + “<br />”);

document.write(“<br />”);
document.write(“<p>Link: ” + txt.link(“http://www.w3schools.com“) + “</p>”);
document.write(“<p><a href=\”http://www.w3schools.com\“>” + txt+ “</a></p>”);

</script>

</body>
</html>

Follow

Get every new post delivered to your Inbox.

Join 65 other followers