I have a JavaScript function that runs when a page loads, and then automatically at a given time interval. The function loops through the images that are delivered in another script (generated by PHP). But whenever this function controls the DOM, the page scrolls back to the top of the div containing the div I am editing. And I really would like to avoid that!
I have already looked at other posts on stackOverflow and other websites, but they are all related to the user action and usually jQuery or Ajax and the anchor link. None of this applies in this situation.
To give you an idea of my HTML:
<div id="the_rest_of_my_page">
<div id="scrolls_to_the top_of_this">
<div id="img_div">
This is where my JavaScript is doing stuff
</div>
</div>
</div>
My JavaScript code is:
function advance_slideshow( )
{
document.getElementById( img_div ).innerHTML = '<img src="' + img_array[index] + '">';
index = (index+1) % img_array.length;
setTimeout('advance_slideshow()', swap_delay);
}
, , .
- , ?
EDIT: , , DOM, div. , , !