Strange JS behavior - any assistance appreciated?
I have a nice little slideshow I got and added to my site. I'm sorry I cannot post the links to it here as it's a private site. Anyway, here is the code that makes it work:
<script>
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x.style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
There is the strangest thing. When I use the code above and the CSS and HTML it works great. The slider does not work automatically; you have to click on the left or right arrows to advance it manually, which is what I want. But then when I take the same code and integrate it into a SharePoint page, everything works except one thing...
When you click the arrows on it, it advances but then in 1 or 2 seconds, it bounces back to the first slide. It's almost as if it suddenly has a mind of its own. Outside of SharePoint and it does not do this at all.
By looking at the JS can anyone see where I could tweak that code so it will not bounce back like it is - even though it does NOT bounce back when it's not in SP? Weird, I know but am just hoping someone can help me.
Thanks.
