Adding Buttons to slide, HTML and Javascript -


i have found following code

how 1 go adapting code in form of adding buttons go forwards , backwards in slideshow.

explaining:

slide forward:

make button following onclick event

<button onclick="slideit()">forward</button> 

if don't want slide change every 2 , halve seconds, put // before line:

settimeout("slideit()",2500); 

or delete it.

slide backward:

<button onclick="slideback()">back</button> 

function sliding backward:

var numslides = ;  function slideback() {    document.images.slide.src = eval("image"+step+".src");    if (step > 1) {       step--;    }    else {       step=numslides;    }  } 

you need set numslides number of slides have.

summary:

html:

<button onclick="slideback()">back</button>     <button onclick="slideit()">forward</button> 

script:

var numslides = ; var autoplay= ;  function slideback() {    document.images.slide.src = eval("image"+step+".src");    if (step > 1) {       step--;    }    else {       step = numslides;    }  }  function slideit() {    var step=1;    document.images.slide.src = eval("image"+step+".src")    if (step < numslides) {       step++    }    else {       step = 1    }    if (autoplay == true) {    settimeout("slideit()",2500)    } } 

set autoplay true/false autoplay, set numslides number of slides


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -