webForumDet fria alternativet

Slupning av layerposition

4 svar · 183 visningar · startad av Jacob

JacobMedlem sedan dec. 2000503 inlägg
#1

jag har en funktion som visar X antal bilder men en fade effect, nu vill jag kunna slumpa positionen för bilderna.

<script language=javaScript>
sandra0 = new Image();
sandra0.src = "sandraaa0.jpg";

sandra1 = new Image();
sandra1.src = "sandraaa1.jpg";

sandra2 = new Image();
sandra2.src = "sandraaa2.jpg";

var i_strngth=1
var i_image=0

var imageurl = new Array()
imageurl[0] ="sandraaa0.jpg"
imageurl[1] ="sandraaa1.jpg"
imageurl[2] ="sandraaa2.jpg"

function showimage() {		
	if(document.all) {
		if (i_strngth <=110) {
			testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
			i_strngth=i_strngth+10
			var timer=setTimeout("showimage()",100)
		}	
		else {
			clearTimeout(timer)
			var timer=setTimeout("hideimage()",1000)
		}
	}	
	
	if(document.layers) {
			clearTimeout(timer)
			document.testimage.document.write("<img src="+imageurl[i_image]+" border=0>")
			document.close()
			i_image++
			if (i_image >= imageurl.length) {i_image=0}	
			var timer=setTimeout("showimage()",2000)
				
	}	
}

function hideimage() {		
	if (i_strngth >=-10) {
		testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
		i_strngth=i_strngth-10
		var timer=setTimeout("hideimage()",100)
	}	
	else {
		clearTimeout(timer)
		i_image++
		if (i_image >= imageurl.length) {i_image=0}
		i_strngth=1
		var timer=setTimeout("showimage()",500)	
	}
}
</script>
<body bgcolor="#FFFFFF" onLoad="showimage()">
<div id="testimage" style="position:absolute;visibility:visible;top:100px;left:500px"></div>

------------------
ja©ob

JohnsenMedlem sedan juli 2000836 inlägg
#2

nu vill jag kunna slumpa positionen för bilderna.

För varje gång en ny bild laddas?

------------------
- J-O-H-N-S-E-N -
------------------

JacobMedlem sedan dec. 2000503 inlägg
#3

Precis

------------------
ja©ob

JohnsenMedlem sedan juli 2000836 inlägg
#4
function fadeimage() {
if (i_strngth <=110) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth+10
var timer=setTimeout("fadeimage()",100)
} 
else {
clearTimeout(timer)
var timer=setTimeout("hideimage()",1000)
} 
}

function showimage() { 
if(document.all) {
testimage.style.left=Math.floor(Math.random()*document.body.clientWidth);
testimage.style.top=Math.floor(Math.random()*document.body.clientHeight);
fadeimage();
} 

if(document.layers) {
clearTimeout(timer)
document.testimage.top=Math.floor(Math.random()*window.innerHeight);
document.testimage.left=Math.floor(Math.random()*window.innerWidth);
document.testimage.document.write("<img src="+imageurl[i_image]+" border=0>")
document.close()
i_image++
if (i_image >= imageurl.length) {i_image=0} 
var timer=setTimeout("showimage()",2000)

} 
}

function hideimage() { 
if (i_strngth >=-10) {
testimage.innerHTML="<img style='filter:alpha(opacity="+i_strngth+")' src="+imageurl[i_image]+" border=0>";
i_strngth=i_strngth-10
var timer=setTimeout("hideimage()",100)
} 
else {
clearTimeout(timer)
i_image++
if (i_image >= imageurl.length) {i_image=0}
i_strngth=1
var timer=setTimeout("showimage()",500) 
}
}

------------------
- J-O-H-N-S-E-N -
------------------

JacobMedlem sedan dec. 2000503 inlägg
#5

Precis vad jag var ute efter, STORT TACK. :e

[Redigerat av Jacob den 10 maj 2001]

127 ms totalt · 3 externa anrop · v20260731065814-full.3ab8d573
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
125 ms — hämta tråd, inlägg och bilagor (db)