I am a newbie JS programmer making my own jQuery based slider. Here is what I have done so far:
HTML:
<div id="keyVisual">
<p id="loading"><span>Loading Content...</span></p>
<ul id="keySlide">
<li id="slideSplash">SPLASH: no pager control on this slide</li>
<li id="slide01"><a href="http://yahoo.com/"></a></li>
<li id="slide02">
<div class="gchild">
<p>grand child content, feedly is a google reader alternative you might want to think.
</p>
<a href="http://feedly.com/" class="link">feedly</a>
</div>
</li>
<li id="slide03">
<div class="gchild">
<p>some grand child content3</p>
<a href="http://yahoo.com" class="link" target="_blank">Yahoo</a>
</div>
</li>
<li id="slide04">
<div class="gchild">
<p>some grand child content4</p>
<a href="http://google.com" class="link" target="_blank">Google</a>
</div>
</li>
</ul>
<div id="btnMoveNext" class="btnSlide"><a href="#">»</a></div>
<div id="btnMovePrev" class="btnSlide"><a href="#">«</a></div>
</div><!-- /#keyVisual -->
<!-- pager -->
<ul id="listTopKey" class="cf">
<li><a href="#slide01" class="no1">No.1</a></li>
<li><a href="#slide02" class="no2">No.2</a></li>
<li><a href="#slide03" class="no3">No.3</a></li>
<li><a href="#slide04" class="no4">No.4</a></li>
</ul>
For JS, please refer to JSFiddle
I have one final problem I hope to solve. At the end of the script, I made a function which watches the load status of background images for each slide. When all the BG images are loaded, the slider starts.
This looks fine first time I visit the page but if I click a link to go somewhere, and then come back to this slider page (using browser back button for example), it seems like the slider fails to go on (just stack in loading scene). Most of the time this works fine in both Google Chrome and Firefox, but not in IE.
I think I need to make some error handling for this situation. I can just think of making a setTimeout
function to fire loader();
after maybe 15 seconds. Any suggestions?
Thank you.
P.S. Feel free to customize or implement the code and use it for your own.