Forum Moderators: open
Would you help me? Please apologize to my broken english.
Thank you very much for your advance.
[edited by: Fotiman at 4:18 pm (utc) on Dec. 1, 2009]
[edit reason] No URLs please. See TOS [webmasterworld.com] [/edit]
<body onload="doThis();">
And then another piece of code that does this:
window.onload = doThat;
In cases like this, only one of those methods will run. The solution would be to either combine both function calls like this:
window.onload = function () {
doThis();
doThat();
}
Or use event listeners instead of event handlers. With event listeners, you can attach as many listeners to an event as you want without them stepping on each other. For example, with jQuery:
$(document).ready(function () {
doThis();
});
// ...
$(document).ready(function () {
doThat();
});
Written at head section:
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var interval = 9.0; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;
var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/saskia-logo1.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo1.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo2.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo3.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo5.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo6.jpg");
image_list[image_index++] = new imageItem("http://example.com/wp-content/themes/classipress/images/header-photo9.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
// End -->
</script>
</head>
and under <body> written:
<body OnLoad="rotateImage('rImage')">
For my scrolling image my code is below, at index.php
<div class="content">
<div class="zeile110">
<script type="text/javascript">
<!--
/***********************************************
* Conveyor belt slideshow script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at [dynamicdrive.com...] for full source code
***********************************************/
//Specify the slider's width (in pixels)
var sliderwidth="980px"
//Specify the slider's height
var sliderheight="100px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=1
//configure background color:
slidebgcolor="#f8f8f8"
//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<img src="http://www.example.com/wp-content/themes/classipress/images/1.jpg" />' //Specify gap between each image (use HTML): //Specify pixels gap between each slideshow rotation (use integer): ////NO NEED TO EDIT BELOW THIS LINE//////////// var copyspeed=slidespeed function fillup(){ function slideleft(){ if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8)) } if (ns_slide2.left>(actualwidth*(-1)+8)) if (iedom¦¦document.layers){ I'm not found code like yours, I don't know what I must to do. [1][edited by: Fotiman at 2:03 pm (utc) on Dec. 2, 2009]
leftrightslide='<img src="http://www.example.com/wp-content/themes/classipress/images/2.jpg" />'
leftrightslide[2]='<img src="http://www.example.com/wp-content/themes/classipress/images/3.jpg" />'
leftrightslide[3]='<img src="http://www.example.com/wp-content/themes/classipress/images/4.jpg" />'
leftrightslide[4]='<img src="http://www.example.com/wp-content/themes/classipress/images/5.jpg" />'
leftrightslide[5]='<img src="http://www.example.com/wp-content/themes/classipress/images/6.jpg" />'
leftrightslide[6]='<img src="http://www.example.com/wp-content/themes/classipress/images/7.jpg" />'
leftrightslide[7]='<img src="http://www.example.com/wp-content/themes/classipress/images/8.jpg" />'
leftrightslide[8]='<img src="http://www.example.com/wp-content/themes/classipress/images/9.jpg" />'
var imagegap=" "
var slideshowgap=2
leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
var iedom=document.all¦¦document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=fillup
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
-->
</script>
</div>
Thank you very much.
[edit reason] Examplified URLs [/edit]
<body OnLoad="rotateImage('rImage')">
But then you also have code that defines window.onload:
window.onload=fillup
So try this.
1. Remove the onload handler from your body tag. Your body tag will then just look like this:
<body>
2. Find this line of code:
window.onload=fillup
And change it to this:
window.onload = function () {
rotateImage('rImage');
fillup();
};