Quantcast
Channel: Forum Pasja Informatyki - Najnowsze pytania
Viewing all articles
Browse latest Browse all 65225

Slider JS - odcinek 2 - uproszczone

$
0
0

Pytanie za 100 punkcikow :) Ponizej sa 2 proste kody(roznia sie tylko ostatnia linia w scrypcie) gdzie jest zrobiony slajder (5ciu zdjec) ktore sie przewijaja co 3 sekundy. 

1szy kod dziala prawidlowo.

2gi kod laduje pierw puste zdjecie... nie rozumiem dlaczego..

Ponizej 1szy kod : 

<script type="text/javascript">
	
	
	
	
	function slajder(){
	
	var Image = document.getElementById('img');
	imageCount = imageCount + 1;
		if (imageCount > total) {
		imageCount = 1;
		}
		if (imageCount < 1){
		imageCount = total;
		}
	
	Image.src="Slajdy/slajd"+imageCount+".png";
	
	}
	
	var imageCount = 1;
	var total = 5;
	setInterval(slajder, 3000);
	
	</script>
	
</head>
<body onload="slajder();">

	<div id="container">
	<img src="Slady/slajd1.png" id="img" />
	
	</div> 

</body>

 

Ponizej 2gi kod gdzie tylko dodalem var countdown na ostatniej lini skryptu i zmienilem funkcje w onload...

<script type="text/javascript">
	
	
	
	
	function slajder(){
	
	var Image = document.getElementById('img');
	imageCount = imageCount + 1;
		if (imageCount > total) {
		imageCount = 1;
		}
		if (imageCount < 1){
		imageCount = total;
		}
	
	Image.src="Slajdy/slajd"+imageCount+".png";
	
	}
	
	var imageCount = 1;
	var total = 5;
	var countdown = setInterval(slajder, 3000);
	
	</script>
	
</head>
<body onload="countdown();">

	<div id="container">
	<img src="Slady/slajd1.png" id="img" />
	
	</div> 

</body>

Tak samo nie rozumiem czemu ten kod pokazuje tez puste zdjecie, a wedlug mnie powinien pokazac slajd2.png.... :

<script type="text/javascript">
	
	function slajder(){
	
	var Image = document.getElementById('img');
	imageCount = imageCount + 1;
		
		}
	
	Image.src="Slajdy/slajd"+imageCount+".png";
	
	}
	
	var imageCount = 1;
	
	
	</script>
	
</head>
<body onload="slajder();">

	<div id="container">
	<img src="Slady/slajd1.png" id="img" />
	
	</div> 

</body>

Z gory dziekuje za pomoc !


Viewing all articles
Browse latest Browse all 65225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>