Nová ukázka
Reset
Načíst z URL
Uložit a získat odkaz
Vztahuje se k…
Nevyplňujte
Napiště „nejsem robot“
▶
Přepnout zobrazení
Výsledek
<meta http-equiv="Content-Language" content="cs"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> <title>JS Náhodný obrázek</title> <style type="text/css"> img {cursor:pointer;} </style> <script> var pozice = 0; var uri_nahledy = ""; var uri_velke = ""; var obrazky = [ "http://www.imagehosting.cz/images/backgruuu.jpg", "http://www.imagehosting.cz/images/picsardnd.jpg", "http://www.imagehosting.cz/images/picsarlll.jpg", "http://www.imagehosting.cz/images/picsarlzl.jpg" ]; function obrZamichej() { var i,pocet, a,a_pozice,b,b_pozice; pocet = obrazky.length; a_pozice = Math.floor(Math.random() * pocet); a = obrazky[a_pozice]; for (i=0;i<pocet*4;i++) { b_pozice = Math.floor(Math.random() * pocet); obrazky[a_pozice] = obrazky[b_pozice]; a_pozice = b_pozice; } obrazky[a_pozice] = a; obrZobraz(); return true; } function obrZobraz() { var a,img; img = '<img src="'+ uri_velke + obrazky[pozice]+'" alt="' + obrazky[pozice] +'" width=""\/>'; a = '<a href="' + uri_nahledy + obrazky[pozice]+'" title="'+ obrazky[pozice] +'" onclick="return !obrOkenko(this)">' + img + '<\/a>'; document.getElementById('obrazek').innerHTML = a; } function obrPosun(krok) { var pocet = obrazky.length - 1; pozice = pozice + krok; pozice = pozice>pocet ? 0 : (pozice<0 ? pocet : pozice); obrZobraz(); } function obrOkenko(odkaz) { var okenko = window.open(odkaz.href,"velky_obrazek","width=100,height=100"); if (okenko.focus) {okenko.focus();} return true; } </script> <body onload="obrZamichej()"> <form action="#" onsubmit="return !obrZamichej()"> <div id="obrazek"></div> <p> <input type="button" value="<<<" onclick="obrPosun(-1)"> <input type="button" value=">>>" onclick="obrPosun(+1)"> </p> </form> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-8453291-23']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </span>
HTML
Autoformát
Standardní režim
Mobilní zobrazení
CSS
Autoformát
CSS reset
Až na konci
J
ava
S
cript
Autoformát
jQuery
Umístění JS
window.onload
</head>
</body>