الخميس، 28 نوفمبر 2013

How to Create JavaScript Image Slideshow with Links


JavaScript Image Slideshow with LInks
 Image Slideshow (Photo credit: Wikipedia)
If you want to place links on the images or captions of the image slideshow using JavaScript codes, you can do it by creating a new array of links along with the array of images and captions and adding some codes on 'swap' function to rotate links with the image and caption rotation in the slideshow. Here  I have written codes for creating JavaScript image slideshow with links, you can use these codes on your website or blog to create attractive image slideshow.

Code for Creating Slideshow with Links on Image


Just copy and paste the code below where you want to place slideshow and change the location of the images.

<script type="text/javascript"> 
var i = 0;
var image = new Array();
// LIST OF IMAGES
image[0] = "image-1.png";
image[1] = "image-2.png";
image[2] = "image-3.png";
var k = image.length-1;

var caption = new Array();
// LIST OF CAPTIONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";

var link= new Array();
// LIST OF LINKS
link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";


function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img = document.getElementById("slide");
img.src= image[i];
var a = document.getElementById("link");
a.href= link[i];

if(i < k ) { i++;}
else { i = 0; }
setTimeout("swapImage()",5000);
}
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() {
swapImage();
});
</script>
<table style="border:none;background-color:transparent;">
<tr>
<td>
<a name="link" id="link" href="http://www.siteforinfotech.com/" target="_blank"><img name="slide" id="slide" alt

="my images" height="285" width="485" src="image-1.png"/></a>
</td>
</tr>
<tr>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<div id ="mydiv"></div>
</td>
</tr>
</table>

Code for Creating Slideshow with Links on Caption


Just copy and paste the code below where you want to place slideshow and change the location of the images.

<script type="text/javascript"> 
var i = 0;
var image = new Array();
// LIST OF IMAGES
image[0] = "image-1.png";
image[1] = "image-2.png";
image[2] = "image-3.png";
var k = image.length-1;

var caption = new Array();
// LIST OF CAPTIONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";

var link= new Array();
// LIST OF LINKS
link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";


function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img = document.getElementById("slide");
img.src= image[i];
var a = document.getElementById("link");
a.href= link[i];

if(i < k ) { i++;}
else { i = 0; }
setTimeout("swapImage()",5000);
}
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() {
swapImage();
});
</script>
<table style="border:none;background-color:transparent;">
<tr>
<td>
<img name="slide" id="slide" alt ="my images" height="285" width="485" src="image-1.png"/>
</td>
</tr>
<tr>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<a name="link" id="link" href="http://www.siteforinfotech.com/" target="_blank"><div id

="mydiv"></div></a>
</td>
</tr>
</table>


You Might also view the following Related Posts

الأربعاء، 27 نوفمبر 2013

Image Slideshow with Navigation Buttons Using Javascript


A simple JavaScript code snippet from Bluefish...
A simple JavaScript code (Photo credit: Wikipedia)

I have already posted JavaScript codes for simple image slideshows without caption, with caption and Jquery fade effect animation. As some of our visitors asked how to add a next button to the slide, I have posted this JavaScript code for creating image slideshow with Navigation Buttons. It may help more for creating awesome image animations for your website or blog.

Code for Creating Image Slideshow with Navigation Buttons 


Just copy and paste the code below where you want to place slideshow and change the location of the images.

<script type="text/javascript"> 
var i = 0;
var image = new Array();
// LIST OF IMAGES
image[0] = "image-1.png";
image[1] = "image-2.png";
image[2] = "image-3.png";
var k = image.length-1;
var caption = new Array();

// LIST OF CAPTIONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";

function next(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img= document.getElementById("slide");
img.src= image[i];
if(i < k ) { i++;}
else { i = 0; }
}

function prev(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img= document.getElementById("slide");
img.src= image[i];
if(i >0 ) { i--;}
else { i = k; }
}

function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img= document.getElementById("slide");
img.src= image[i];
if(i < k ) { i++;}
else { i = 0; }
setTimeout("swapImage()",5000);
}
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() {
swapImage();
});
</script>
<table style="border:none;background-color:transparent;">
<tr>
<td>
<img onclick="prev()" title="Previous" alt ="Prev" height="25" width="15"src="prev.jpg"/>
</td>
<td>
<img name="slide" id="slide" alt ="my images" height="285" width="485" src="image-1.png"/>
</td>
<td>
<img onclick="next()" title="Next" alt ="Next" height="25" width="15" src="next.jpg"/>
</td>
</tr>
<tr>
<td>
</td>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<div id ="mydiv"></div>
</td>
<td>
</td>
</tr>
</table>


You Might also view the following Related Posts

الخميس، 21 نوفمبر 2013

Solved Objective Questions on Operating System set-8


1. A small program which loads OS into the memory is called as ...........
Objective Questions on Operating System
System management components (Photo credit: Wikipedia)

A) ROM

B) bootstrap loader

C) BIOS

D) RAM



2. Virtual memory is ..............

A) Simple to implement

B) Used by all major commercial OS

C) Less efficient memory utilization

D) Less effective



3. A special purpose register that is set to the highest address occupied by the OS code is ...........

A) fence register

B) general purpose register

C) protection register

D) control register



4. As OS program module that selects the next job to be admitted for execution is called as .....

A) scheduler

B) compiler

C) throughput

D) dispatcher





5. Multiprogramming systems .................

A) are easier to develop than single programming systems.

B) execute each job faster

C) execute more jobs in the same time.

D) are used only on large main frame computers



6. SSTF stands for ........................

A) Small seek Time First

B) Simple Seek Time First

C) Shortest Seek Time First

D) Synchronous Seek Time First



7. The program is known as .................. which interacts with the inner part of called kernel.

A) compiler

B) device driver

C) protocol

D) shell



8. Semaphore can be used for solving ............

A) wait & signal

B) deadlock

C) synchronization

D) priority



9. The number of processes completed per unit time is known as ............

A) output

B) throughput

C) efficiency

D) capacity



10. On what principle does Distributed OS work?

A) File foundation

B) Single system image

C) Multi system image

D) Networking image


Answers:



1. A small program which loads OS into the memory is called as ...........

B) bootstrap loader

2. Virtual memory is ..............

B) Used by all major commercial OS

3. A special purpose register that is set to the highest address occupied by the OS code is ...........

A) fence register

4. As OS program module that selects the next job to be admitted for execution is called as .....

A) scheduler

5. Multiprogramming systems .................

C) execute more jobs in the same time.

6. SSTF stands for ........................

C) Shortest Seek Time First

7. The program is known as .................. which interacts with the inner part of called kernel.

D) shell

8. Semaphore can be used for solving ............

C) synchronization

9. The number of processes completed per unit time is known as ............

B) throughput

10. On what principle does Distributed OS work?

B) Single system image



Related Posts:


الأربعاء، 13 نوفمبر 2013

Solved MCQ Questions on Operating System set-7


1. Operating System means ........................

A) a set of programs which controls computer working.

MCQ Questions on Operating System
Operating System (Photo credit: Wikipedia)
B) a way of computer drives works

C) a set of devices and programs

D) All of the above



2. The basic types of OS are ...................

A) batch and time sharing

B) sequential and real time

C) direct and interactive

D) batch and interactive



3. The simplest way of deadlock is to ...

A) preempt a resource

B) rollback

C) kill one of the processes

D) lock one of the processes



4. Throughput of a system is

A) Number of programs processed by it per unit time

B) Number of times the program is invoked by the system

C) Number of requests made to a program by the system

D) None of the above



5. Which of the following is not OS layer?

A) Kernel

B) Shell

C) Application Programs

D) Critical Section



6. Round robin scheduling is essentially the preemptive version of ...........

A) first in first out

B) shortest job first

C) shortest remaining

D) longest time first



7. The process that are residing in the main memory and are waiting to execute are kept on a list called the ............

A) job queue

B) ready queue

C) wait queue

D) device queue



8. Which of the following describes the ability of an OS to support multiple, concurrent paths of execution within a single process?

A) Multithreading

B) Multiprocessing

C) Multitasking

D) Multiprogramming



9. Virtual memory is

A) an extremely large main memory

B) an extremely large secondary memory

C) an illusion of extremely large main memory

D) a type of memory used in super computers



10. A thread is a .................... precess.

A) heavy weight

B) multiprocess

C) inter thread

D) light weight






Answers:


1. Operating System means ........................

A) a set of programs which controls computer working.

2. The basic types of OS are ...................

D) batch and interactive

3. The simplest way of deadlock is to ...

C) kill one of the processes

4. Throughput of a system is

A) Number of programs processed by it per unit time

5. Which of the following is not OS layer?

D) Critical Section

6. Round robin scheduling is essentially the preemptive version of ...........

A) first in first out

7. The process that are residing in the main memory and are waiting to execute are kept on a list called the ............

B) ready queue

8. Which of the following describes the ability of an OS to support multiple, concurrent paths of execution within a single process?

A) Multithreading

9. Virtual memory is

C) an illusion of extremely large main memory

10. A thread is a .................... precess.

D) light weight



Related Posts:

السبت، 9 نوفمبر 2013

Solved MCQ of Programming in C++ set-5


1. There is a unique function in C++ program by where all C++ programs start their execution with ........

A) start()
Solved MCQ of Programming in C++
 Class diagram of C++ programming(Photo credit: Wikipedia)

B) begin()

C) main()

D) output()



2. Which of the following is not a jump statement in C++?

A) break

B) Goto

C) Exit

D) Switch



3. The memory address of the first element of an array is called ...................

A) floor address

B) foundation address

C) first address

D) base address



4. C++ exception handling mechanism mainly uses how many keywords?

A) Four

B) Three

C) Two

D) None of the above



5. When an exception is thrown, it needs to be .....................

A) Executed

B) Handled appropriately

C) Resolved

D) None of the above



6. After defining the function template, the next step to call it in another function such as .........

A) int()

B) secondary()

C) template()

D) main()



7. A file stream refers to the flow of data between a ...............

A) Program and object

B) Program and stream

C) Program and file

D) None of the above




8. .................. are one of the attributes of C++ that support run-time polymorphism.

A) Pointers

B) Derived classes

C) Virtual functions

D) Heap tree



9. which of the following header file does not exist?

A) iostream

B) string

C) sstring

D) sstream



10. To increase the value of c by one, which of the following is wrong?

A) c++;

B) c=c+1;

C) c+1=>c;

D) c+=1;





Answers:



1. There is a unique function in C++ program by where all C++ programs start their execution with ........

C) main()

2. Which of the following is not a jump statement in C++?

D) Switch

3. The memory address of the first element of an array is called ...................

D) base address

4. C++ exception handling mechanism mainly uses how many keywords?

B) Three

5. When an exception is thrown, it needs to be .....................

B) Handled appropriately

6. After defining the function template, the next step to call it in another function such as .........

D) main()

7. A file stream refers to the flow of data between a ...............

C) Program and file

8. .................. are one of the attributes of C++ that support run-time polymorphism.

C) Virtual functions

9. which of the following header file does not exist?

C) sstring

10. To increase the value of c by one, which of the following is wrong?

C) c+1=>c;


Related Posts


Enhanced by Zemanta

الأربعاء، 6 نوفمبر 2013

Solved MCQ of Programming in C set-3


Solved MCQ of Programming in C
Dependency graph for tgmath.h header file in C Programming Language (Photo credit: Wikipedia)
1. C language is available for which of the following operating systems?

A) DOS

B) Windows

C) Unix

D) All of the above


2. Which of the following are tokens in C?

A) Keywords

B) Variables

C) Constraints

D) All of the above


3. C was developed in the year .....................

A) 1970

B) 1972

C) 1976

D) 1980


4. Which escape character can be used to beep from speaker in C?

A) \a

B) \b

C) \m

D) \n


5. Which of the following is a keyword is used for storage class?

A) printf

B) external

C) auto

D) scanf


6. Continue statement is used .............

A) to go to the next iteration in a loop

B) come out of a loop

C) exit and return to the main function

D) restarts iteration from beginning of loop


7. File manipulation functions in C are available in which header file?

A) streams.h

B) stdio.h

C) stdlib.h

D) files.h


8. A compiler ................

A) is a computer program

B) translates a high level language into machine language

C) is a part of software

D) editor


9. Explicit type conversion is known as ....................

A) casting

B) conversion

C) disjunction

D) separation


10. A function popularly used C input function

A) scanf

B) printf

C) getch

D) Char



Answers:



1. C language is available for which of the following operating systems?

D) All of the above

2. Which of the following are tokens in C?

D) All of the above

3. C was developed in the year .....................

A) 1970

4. Which escape character can be used to beep from speaker in C?

B) \b

5. Which of the following is a keyword is used for storage class?

C) auto

6. Continue statement is used .............

A) to go to the next iteration in a loop

7. File manipulation functions in C are available in which header file?

B) stdio.h

8. A compiler ................

B) translates a high level language into machine language

9. Explicit type conversion is known as ....................

A) casting

10. A function popularly used C input function

A) scanf


Related Posts