DHTML Fading Animation Image
Enhancing image presentation on your website with this image rotator plus smooth dynamic motion (fade-in-fade-out). A very great anima... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup
Step 1: Use JavaScript code below to setup the script
JavaScript
Code:
<SCRIPT language=javaScript>
<!-- Beginning of JavaScript -
sandra0 = new Image();
sandra0.src = "photo1.jpg";
sandra1 = new Image();
sandra1.src = "photo2.jpg";
sandra2 = new Image();
sandra2.src = "photo3.jpg";
var i_strngth=1
var i_image=0
var imageurl = new Array()
imageurl[0] ="photo1.jpg"
imageurl[1] ="photo2.jpg"
imageurl[2] ="photo3.jpg"
function showimage() {
if(document.all) {
if (i_strngth <=110) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth+10
var timer=setTimeout("showimage()",100)
}
else {
clearTimeout(timer)
var timer=setTimeout("hideimage()",1000)
}
}
if(document.layers) {
clearTimeout(timer)
document.testimage.document.write("<img src="+imageurl[i_image]+" border=0>")
document.close()
i_image++
if (i_image >= imageurl.length) {i_image=0}
var timer=setTimeout("showimage()",2000)
}
}
function hideimage() {
if (i_strngth >=-10) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth-10
var timer=setTimeout("hideimage()",100)
}
else {
clearTimeout(timer)
i_image++
if (i_image >= imageurl.length) {i_image=0}
i_strngth=1
var timer=setTimeout("showimage()",500)
}
}
// - End of JavaScript - -->
</SCRIPT>
Step 2: Copy & Paste HTML code below in your BODY section
HTML
Code:
<BODY onload=showimage()>
<DIV id=mainbod style="POSITION: relative; VISIBILITY: visible"></DIV>
<DIV id=testimage style="POSITION: relative; VISIBILITY: visible"></DIV>
</BODY>
JavaScript Countdown Timer solution in OOP
This JavaScript code is the new & unique solution to create a countdown timer on your web pages; it's really new in the look of web developers and users. This JavaScript countdown timer is very ea... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup
Step 1: Use CSS code below for styling the script
CSS
Code:
<style type="text/css">
body{
font-family:arial,sans-serif;
color:#000;
background:#fff;
text-align:center;
}
input{
font-size:20px;
padding:5px;
border:none;
background:#69c;
margin:0 10px;
}
input#c[disabled]{
background:#eee;
}
#display{
font-weight:bold;
margin:20px auto;
width:720px;
font-size:350px;
}
.final{
color:#c00;
}
.over{
color:#c00;
text-decoration:blink;
}
#preferences{
margin-top:.5em;
background:#ccc;
border-top:1px solid #999;
padding:2em;
font-size:1em;
text-align:left;
}
#preferences p {
width:49%;
float:left;
padding:5px 0;
margin:0;
position: absolute;
top: 0px;
}
#preferences input{
font-size:20px;
padding:5px;
border:1px solid #999;
background:#fff;
margin:0 2px;
}
#preferences label{
padding-top:10px;
width:30%;
float:left;
display:block;
padding-right:1em;
}
#preferences input#set{
font-size:20px;
padding:5px;
width:600px;
margin:0 auto;
border:none;
background:#69c;
clear:both;
display:block;
}
#preferences input#set:hover{
background:#ffc;
}
</style>
Step 2: Copy & Paste JavaScript code below in your HEAD section
JavaScript
Code:
<script>
countdown = function(){
/*
configuration of script, properties with
values and labels will become form elements!
*/
var cfg = {
displayID:'display',
preferencesID:'preferences',
finalClass:'final',
overClass:'over',
initialText:{
value:'2:00',
label:'Initial Text'
},
seconds:{
value:2*60,
label:'Time in Seconds'
},
finalCountdown:{
value:30,
label:'Warning start'
},
pauseLabel:{
value:'pause',
label:'Pause Text'
},
resumeLabel:{
value:'resume',
label:'Resume Text'
},
resetLabel:{
value:'reset',
label:'Reset Text'
},
startLabel:{
value:'start',
label:'Start Text'
}
};
/* presets */
var seconds = cfg.seconds.value;
var interval = null;
var secs = null;
var startTime = null;
var realsecs = null;
/* create display */
var display = document.createElement('div');
display.id = cfg.displayID;
document.body.appendChild(display);
display.innerHTML = cfg.initialText.value;
/* create form with buttons */
var form = document.createElement('form');
document.body.appendChild(form);
var startButton = createInput('button','startButton',cfg.startLabel.value);
startButton.onclick = startCountDown;
form.appendChild(startButton);
var pauseButton = createInput('button','pauseButton',cfg.pauseLabel.value);
pauseButton.onclick = pauseCountDown;
pauseButton.disabled = true;
form.appendChild(pauseButton);
var resetButton = createInput('button','resetButton',cfg.resetLabel.value);
resetButton.onclick = resetCountDown;
form.appendChild(resetButton);
/* create preferences panel */
var preferencesPanel = document.createElement('div');
preferencesPanel.id = cfg.preferencesID;
preferencesPanel.style.display = 'none';
var firstForm = document.getElementsByTagName('form')[0];
firstForm.appendChild(preferencesPanel);
var button = createInput('button',null,'preferences');
button.onclick = togglePreferences;
preferencesPanel.parentNode.insertBefore(button,preferencesPanel);
/* create preferences form */
var prefs = [];
for (var i in cfg){
if(cfg[i].value){
prefs.push(i);
var p = document.createElement('p');
p.appendChild(createLabel(cfg[i].label,i));
p.appendChild(createInput('text',i,cfg[i].value));
preferencesPanel.appendChild(p);
}
}
var setPreferencesButton = createInput('button','set','set');
preferencesPanel.appendChild(setPreferencesButton);
setPreferencesButton.onclick = setPreferences;
function setPreferences(){
for(var i=0,j=prefs.length;i<j;i++){
cfg[prefs[i]].value = document.getElementById(prefs[i]).value;
}
resetCountDown();
preferencesPanel.style.display = 'none';
}
function togglePreferences(){
preferencesPanel.style.display = preferencesPanel.style.display === 'none' ? 'block' : 'none';
}
function startCountDown(){
pauseButton.disabled = false;
startButton.disabled = true;
startTime = new Date();
interval = setInterval(countdown.doCountDown, 100);
}
function doCountDown(){
realsecs = Math.ceil(seconds - (new Date() - startTime) / 1000);
var mins = parseInt(realsecs / 60);
var secs = realsecs % 60;
display.innerHTML = parseInt(mins) + ':'+ (secs < 10 ? '0' : '') +(secs % 60);
display.className = (realsecs > cfg.finalCountdown.value) ? '' : cfg.finalClass;
if(realsecs===0){
display.className = cfg.overClass;
window.clearTimeout(interval);
}
}
function resetCountDown(){
window.clearTimeout(interval);
startButton.disabled = false;
pauseButton.disabled = true;
display.innerHTML = cfg.initialText.value;
interval = null;
seconds = cfg.seconds.value;
pauseButton.value = cfg.pauseLabel.value;
resetButton.value = cfg.resetLabel.value;
startButton.value = cfg.startLabel.value;
display.className = '';
}
function pauseCountDown(){
if(pauseButton.value === cfg.pauseLabel.value){
seconds = realsecs;
window.clearTimeout(interval);
pauseButton.value = cfg.resumeLabel.value;
} else {
startCountDown();
pauseButton.value = cfg.pauseLabel.value;
}
}
function createInput(type,id,value){
var input = document.createElement('input');
input.value = value;
input.type = type;
if(id){
input.id = id;
}
return input;
}
function createLabel(text,id){
var label = document.createElement('label');
label.appendChild(document.createTextNode(cfg[id].label));
label.htmlFor = id;
return label;
}
return {doCountDown:doCountDown};
}();
</script>
Streaming Horizontal Banner
Use this JavaScript code to make a a horizontal image scroller on your web page. If do not view the source code, maybe you will think tha... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup
Step 1: Copy & Paste CSS code below in your HEAD section
CSS
Code:
<style type="text/css">
<!--
#slideCont {
border:solid 1px #000;
text-align:center;
}
#slideCont img {
margin: 5px;
}
-->
</style>
Step 2: Place JavaScript below in your HEAD section
JavaScript
Code:
<script type="text/javascript">
<!--
/*
-----------------------------------------------
Streaming banners - v.1
(c) 2006 www.haan.net
You may use this script but please leave the credits on top intact.
Please inform us of any improvements made.
When usefull we will add your credits.
------------------------------------------------ */
<!--
function clip() {
// width of the banner container
var contWidth = 425;
// height of the banner container
var contHeight = 90;
var id1 = document.getElementById('slideA');
var id2 = document.getElementById('slideB');
id1.style.left = parseInt(id1.style.left)-1 + 'px';
document.getElementById('slideCont').style.width = contWidth + "px";
document.getElementById('slideCont').style.clip = 'rect(auto,'+ contWidth +'px,' + contHeight +'px,auto)';
id2.style.display = '';
if(parseFloat(id1.style.left) == -(contWidth)) {
id1.style.left = '0px';
}
setTimeout(clip,25)
}
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
clip();
});
//-->
</script>
Step 3: Copy & Paste HTML code below in your BODY section
HTML
Code:
<div id="slideCont" style="overflow: hidden; position: relative; z-index: 1; width: 425px; height: 90px; top: 0px; clip: rect(auto, 425px, 90px, auto);">
<div id="slideA" style="overflow: hidden; position: absolute; z-index: 1; top: 0px; left: -194px; width: 850px; height: 90px;">
<div style="float: left;" id="innerSlideA">
<a href="http://www.apache.org/"><img src="/logos/logo_jsbank.jpg" border="0" height="44" width="126"></a>
<a href="http://www.haan.net/"><img src="/logos/gif_logojsb2.gif" border="0" height="60" width="120"></a>
<a href="http://www.mysql.com/"><img src="/logos/jsb_banner.gif" border="0" height="44" width="126"></a>
</div>
<div id="slideB" style="overflow: hidden; position: relative; z-index: 1; top: 0px; left: 0px; width: 425px; height: 90px;">
<a href="http://www.apache.org/"><img src="/logos/logo_jsb.jpg" border="0" height="44" width="126"></a>
<a href="http://www.haan.net/"><img src="/logos/logo_jsb__88x31.gif" border="0" height="60" width="120"></a>
<a href="http://www.mysql.com/"><img src="/logos/logo_jsb_120x60.jpg" border="0" height="44" width="126"></a>
</div>
</div>
</div>
Expanding Navigation Menu onClick
This is a simple expand collapse menu. The anchor tags that expand each menu are added by JavaScript, so the HTML code doesn't contain any event handlers or unnecessary HTML tags. The ... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup
Step 1: Copy & Paste CSS code below in your HEAD section
CSS
Code:
<style type="text/css">
ul#menu {
width: 100px;
list-style-type: none;
border-top: solid 1px #b9a894;
margin: 0;
padding: 0;
}
ul#menu ol {
display: none;
text-align: right;
list-style-type: none;
margin: 0;
padding: 5px;
}
ul#menu li,
ul#menu a {
font-family: verdana, sans-serif;
font-size: 11px;
color: #785a3c;
}
ul#menu li {
border-bottom: solid 1px #b9a894;
line-height: 15px;
}
ul#menu ol li {
border-bottom: none;
}
ul#menu ol li:before {
content: "-";
}
ul#menu a {
text-decoration: none;
outline: none;
}
ul#menu a:hover {
color: #539dbc;
}
ul#menu a.active {
color: #be5028;
}
</style>
Step 2: Place JavaScript below in your HEAD section
JavaScript
Code:
<script language="javascript">
/*
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com
version date: 06/02/03 :: If want to use this code, feel free to do so,
but please leave this message intact. (Travis Beckham) */
// Node Functions
if(!window.Node){
var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}
function checkNode(node, filter){
return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}
function getChildren(node, filter){
var result = new Array();
var children = node.childNodes;
for(var i = 0; i < children.length; i++){
if(checkNode(children[i], filter)) result[result.length] = children[i];
}
return result;
}
function getChildrenByElement(node){
return getChildren(node, "ELEMENT_NODE");
}
function getFirstChild(node, filter){
var child;
var children = node.childNodes;
for(var i = 0; i < children.length; i++){
child = children[i];
if(checkNode(child, filter)) return child;
}
return null;
}
function getFirstChildByText(node){
return getFirstChild(node, "TEXT_NODE");
}
function getNextSibling(node, filter){
for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
if(checkNode(sibling, filter)) return sibling;
}
return null;
}
function getNextSiblingByElement(node){
return getNextSibling(node, "ELEMENT_NODE");
}
// Menu Functions & Properties
var activeMenu = null;
function showMenu() {
if(activeMenu){
activeMenu.className = "";
getNextSiblingByElement(activeMenu).style.display = "none";
}
if(this == activeMenu){
activeMenu = null;
} else {
this.className = "active";
getNextSiblingByElement(this).style.display = "block";
activeMenu = this;
}
return false;
}
function initMenu(){
var menus, menu, text, a, i;
menus = getChildrenByElement(document.getElementById("menu"));
for(i = 0; i < menus.length; i++){
menu = menus[i];
text = getFirstChildByText(menu);
a = document.createElement("a");
menu.replaceChild(a, text);
a.appendChild(text);
a.href = "#";
a.onclick = showMenu;
a.onfocus = function(){this.blur()};
}
}
if(document.createElement) window.onload = initMenu;
</script>
Step 3: Copy & Paste HTML code below in your BODY section
HTML
Code:
<ul id="menu">
<li>Menu Item 1
<ol>
<li><a href="#">Sub Item 1.1</a></li>
<li><a href="#">Sub Item 1.2</a></li>
<li><a href="#">Sub Item 1.3</a></li>
</ol>
</li>
<li>Menu Item 2
<ol>
<li><a href="#">Sub Item 2.1</a></li>
<li><a href="#">Sub Item 2.2</a></li>
<li><a href="#">Sub Item 2.3</a></li>
</ol>
</li>
<li>Menu Item 3
<ol>
<li><a href="#">Sub Item 3.1</a></li>
<li><a href="#">Sub Item 3.2</a></li>
<li><a href="#">Sub Item 3.3</a></li>
</ol>
</li>
<li>Menu Item 4
<ol>
<li><a href="#">Sub Item 4.1</a></li>
<li><a href="#">Sub Item 4.2</a></li>
<li><a href="#">Sub Item 4.3</a></li>
</ol>
</li>
<li>Menu Item 5
<ol>
<li><a href="#">Sub Item 5.1</a></li>
<li><a href="#">Sub Item 5.2</a></li>
<li><a href="#">Sub Item 5.3</a></li>
</ol>
</li>
</ul>
Slideshow with zoom-in-zoom-out-animation
Slideshow with great transitoon effect. Each image has a JavaScript link of its own. Netscape-users will see a simple image-rotation-ef... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup
Step 1: Place HTML below in your BODY section
HTML
Code:
<BODY onload=initiate()>
<SCRIPT>
<!-- Beginning of JavaScript -
// Slideshow with zoom-in-zoom-out-animation
// CONFIGURATION:
// 1. Create your images (gif or jpg). They should have the same width.
// Put those images in the same directory as the HTML-file.
// You can add as many images as you like.
// 2. Copy the script-block and paste it into head-section of your HTML-file..
// 3. Copy the span-blocks with the id "imgcontainer" into the body-section
// of your HTML-file.
// 4. Insert 'onLoad="initiate()"' into the body tag.
// 5. Configure the varibales below.
// The width of your images (pixels). All pictures should have the same width.
var imgwidth=256
// The horizontal and vertical position of the images (pixels).
var pos_left=10
var pos_top=10
// The name of your images. You may add as many images as you like.
var imgname=new Array()
imgname[0]="logojs.gif"
imgname[1]="photo3.jpg"
imgname[2]="photo4.jpg"
// Where should those images be linked to?
// Add an URL for each image.
// If you don't want to add an URL just write '#' instead of the URL.
var imgurl=new Array()
imgurl[0]="http://javascriptbank.com"
imgurl[1]="http://javascriptbank.com"
imgurl[2]="http://javascriptbank.com"
// This block will preload your images. Do not edit this block.
var imgpreload=new Array()
for (i=0;i<=imgname.length-1;i++) {
imgpreload[i]=new Image()
imgpreload[i].src=imgname[i]
}
// Standstill-time between the images (microseconds).
var pause=2000
// Speed of the stretching and shrinking effect. More means slower.
var speed=20
// This variable also affects the speed (the length of the step between each inmage-frame measured in pixels). More means faster.
var step=10
// Do not edit the variables below
var i_loop=0
var i_image=0
function stretchimage() {
if (i_loop<=imgwidth) {
if (document.all) {
imgcontainer.innerHTML="<a href='"+imgurl[i_image]+"' target='_blank'><img width='"+i_loop+"' src='"+imgname[i_image]+"' border='0'></a>"
}
i_loop=i_loop+step
var timer=setTimeout("stretchimage()",speed)
}
else {
clearTimeout(timer)
var timer=setTimeout("shrinkimage()",pause)
}
}
function shrinkimage() {
if (i_loop>-step) {
if (document.all) {
imgcontainer.innerHTML="<a href='"+imgurl[i_image]+"' target='_blank'><img width='"+i_loop+"' src='"+imgname[i_image]+"' border='0'></a>"
}
i_loop=i_loop-step
var timer=setTimeout("shrinkimage()",speed)
}
else {
clearTimeout(timer)
changeimage()
}
}
function changeimage() {
i_loop=0
i_image++
if (i_image>imgname.length-1) {i_image=0}
var timer=setTimeout("stretchimage()",pause)
}
function initiate() {
if (document.all) {
document.all.imgcontainer.style.posLeft=pos_left
document.all.imgcontainer.style.posTop=pos_top
changeimage()
}
if (document.layers) {
document.imgcontainer.left=pos_left
document.imgcontainer.top=pos_top
rotatenetscape()
}
}
function rotatenetscape() {
document.imgcontainer.document.write("<a href='"+imgurl[i_image]+"' target='_blank'><img src='"+imgname[i_image]+"' border='0'></a>")
document.imgcontainer.document.close()
i_image++
if (i_image>imgname.length-1) {i_image=0}
var timer=setTimeout("rotatenetscape()",pause*2)
}
document.write("<div id=\"roof\" style=\"position:relative\">")
document.write("<div id=\"imgcontainer\" style=\"position:absolute;top:0px;left:0px\"></div>")
document.write("</div>")
// - End of JavaScript - -->
</SCRIPT>
</BODY>
<!--
This script downloaded from www.JavaScriptBank.com
Come to view and download over 2000+ free javascript at www.JavaScriptBank.com
-->
Helpful JavaScript resources for Designers
Web Design - a task that requires the creativity and a lot of time, to create the high quality products. However, in the environment of modern web nowadays, the Internet produced a lot of libraries, u... detail at JavaScriptBank.com - 2.000+ free JavaScript codes
How to setup