html5 - javascript image slider hyperlinks -
i working on website , client wants image slider each slide links different page on site. prefer if stay in javascript cant seem wrap head around jquery. here code
javascript code in header
`<script type="text/javascript"> <!-- var img1 = new image() img1.src="downtowneventnew.jpg" var img2 = new image() img2.src="shakespeare.jpg" var img3 = new image() img3.src="downtownconcertnew.jpg" var img4 = new image() img4.src="rangerettes.jpg" //--> </script>
html 5 , javascript in body
<div class="content"> <div id="slide"> <div class="slide_container"> <a href="restaurants.html"><img src="downtowneventnew.jpg" name="slide" /> </a> <script type="text/javascript"> <!-- var pic =1 function slides() { if (!document.images) return document.images.slide.src=eval("img" +pic+".src") if (pic < 4) pic++ else pic =1 settimeout("slides()",5000) } slides() //--> </script> </div> </div>
use plugin nivo slider (that way don't need develop jquery scratch), , wrap image in anchor tag <a>
:
<div id="slider"> <img src="images/thing.jpg" alt="no link" /> <a href="http://www.cnn.com"><img src="images/thing2.jpg" title="link!" /></a> </div>
Comments
Post a Comment