javascript - Why does this script start with a blank image? -
javascript - Why does this script start with a blank image? -
i'm using script scroll through images in iframe. can't figure out how script start on image 1 rather start blank , go image 1.
here script:
<script type="text/javascript"> var limit = 8; var = limit - 1; function image_onclick(direction) { = ( + ( (direction == 'prev')?limit-1:1 ) ) % limit; document.getelementbyid('image_box').innerhtml = '<img src=images/gallery/image' + (i+1) + '.jpg>'; } </script> this script in body,
<div id="leaf1"><button onclick="image_onclick('prev');"><img src="images/leaf.gif" alt="leaf arrow" border="0"/></button></div> <div id="image_box"></div> <div id="leaf2"><button onclick="image_onclick('next');"><img src="images/leaf2.gif" alt="leaf arrow" border="0"/></button></div>
use window.load or document.ready method , add together next code it.
document.getelementbyid('image_box').innerhtml = '<img src=images/gallery/image1'.jpg>'; or on page
<script language="javascript"> document.getelementbyid('image_box').innerhtml = '<img src=images/gallery/image1'.jpg>'; </script> javascript
Comments
Post a Comment