الأربعاء، 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:

الأربعاء، 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