Let's clean up your code. Try:
Code:
<script type="text/javascript">
function GotoPic(Num){
return location.pathname + '?' + Num;
}
var Picture = new Array;
Picture.push("imagename.jpg");
Picture.push("imagename2.jpg");
Picture.push("imagename3.jpg");
Picture.push("imagename4.jpg");
var ThisPic,
PrevPic,
NextPic,
ShowPrev,
ShowNext;
if (location.search)
ThisPic = location.search.substring(1) * 1;
else
ThisPic = 0;
NextPic = ThisPic + 1;
ShowNext = NextPic > (Picture.length - 1);
PrevPic = ThisPic - 1;
ShowPrev = PrevPic < 0;
if (ShowPrev)
document.writeln('<a href="javascript:GotoPic(PrevPic);"><img src="navigation/previous.jpg" width="75" height="23" border="0"></a><img src="navigation/blank.jpg"> ');
if (ShowNext)
document.writeln('<a href="javascript:GotoPic(NextPic)"><img src="navigation/next.jpg" width="37" height="23" border="0"></a> ');
document.write('</P><img src="'+Picture[ThisPic]+'">');
</script>
I haven't made any major changes here, just cleaned up your code a little to avoid some bad practices. However, the route you've taken to accomplish this slideshow is a rather circuitous and clunky one. Is there any particular reason you've done it this way, or may I clean up your method as well?
Bookmarks