I need to repositioning a javascript slideshow using css?
Hi,
I am a total Newbie to javascript and I have been trying for 5 hrs now to use CSS to reposition the slideshow see code below, and it won't work.
Can anybody help?
This is my Javascript in HTML
<div id="slideshow">
<script type="text/javascript">
var pictureArchive= ['1.jpg','2.jpg','3.jpg','4.jpg'];
window.onload=function() {
var o=document.createElement('img');
o.setAttribute('id', 'image');
o.setAttribute('src', pictureArchive[0]);
o.setAttribute('alt', '');
document.body.appendChild(o);
rotate(pictureArchive.length);
left=400;
}
function rotate(idx) {
if(idx>=pictureArchive.length) {
idx=0;
}
document.getElementById('image').src=pictureArchive[idx++];
timerID=setTimeout('rotate('+idx+')', 4000);
}
</script>
</div>
This is my CSS
#slideshow{
width:375px;
height:332px;
position:absolute;
top:35px;
left:363px;
}
Thank you Fang I owe you a pint
I can't thank you enough .
Its worked , its worked - cheers!
Positioning the Image Output
How can I control the position where the output will be displayed by the function below? For example, I want to display the picture output between two paragraphs.
<H1>this is the bottom page</H1>
<script type="text/javascript">
window.onload=function display_pics() {
var o=document.createElement('img');
o.setAttribute('id', 'image');
o.setAttribute('src', pictureArchive[0]);
alert (pictureArchive[0].src);
o.setAttribute('alt', '');
document.body.appendChild(o);
rotate(pictureArchive.length);
}
</script>
<H1>this is the bottom page</H1>
Images with Redirected HREFs
I created 2 arrays for the href links
var pictureArchive= ['1.jpg','2.jpg','3.jpg','4.jpg'];
var hrefArchive= ['http://1.com','http://2.com','http://3.com','http://4.com'];
how would I incorporate the array to the function rotate(idx) and window.onload=function() ?
Can you also suggest a site with good tutorial on using "document.getElementById"?