Javascript
Hej EksperterJeg er igang med at opsætte en side via javascript, som skal bestå af en masse billeder.
Problemet ligger i at jeg ikke kan få min side til at vise nye/random billeder når de kommer ind på siden (det er altså det samme billede der altid er "forsiden" selvom det burde være et random/nyt billede.)
Jeg gør brug af et script med knapper til "Next" "Previous" og "Random" som fungere helt perfekt.
Det der ligger i det, er at jeg ikke ved hvad jeg skal ændre i mit script for at det bliver muligt at gøre det til random/nyt billede hver gang en person refresher siden eller kommer ind på den igen.
Håber der er nogle eksperter der kan hjælpe med problemet
På forhånd mange gange tak!
MvH Martin H Sparsø
Scriptet:
_______________________________________________
<HTML>
<HEAD><TITLE>reklameklik.dk</TITLE>
<META content=0 http-equiv=Expires>
<STYLE>
body, td, p {font-size: 12pt; font-family: times new roman, times, serif}
h1 {font-weight: normal; font-size: 26pt; font-family: arial, helvetica, sans-serif}
h2 {font-weight: normal; font-size: 18pt; font-family: arial, helvetica, sans-serif}
h3 {font-weight: normal; font-size: 16pt}
h4 {font-weight: normal; font-size: 14pt}
a {text-decoration: none}
a:hover {text-decoration: underline}
</STYLE>
<SCRIPT language="JavaScript">
<!-- Hide from old browsers
var i = 1
images = new Array
images[1] = "http://doonyellowpages.com/plog-content/thumbs/funny/funny/large/13-funny-cat-ninja.jpg"
images[2] = "http://cl.jroo.me/z3/M/Y/F/d/a.aaa-Funny-Man-RoFl.jpg"
images[3] = "http://cdn.humorswitch.com/wp-content/uploads/2012/02/Indeed.jpg"
images[4] = "http://www.twing.in/wp-content/uploads/2011/12/funny_adult_bathing.jpg"
images[5] = "http://s4.images.drive2.ru/user.blog.photos/x7/0400/000/000/3e1/f15/48ced9a480e721a7-main.jpg"
images[6] = "http://mycommentcodes.com/comments/funny/funny-06.jpg"
function gallery(){
if (i == 1){
document.gallery.previous.value=" "}
}
function previmg(){
if (i != 1) {
i --
document.img.src = images[i]
document.gallery.next.value = "Next"}
if (i == 1) {
document.gallery.previous.value=" "}
}
function nextimg(){
if (i != 6) {
i ++
document.gallery.previous.value="Previous"
image = images[i]
document.img.src = image}
if (i == 6){
document.gallery.next.value=" ";}
}
function pickrand(){
var imagenumber = 6 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1;
var randimage = images[rand1]
document.img.src = randimage
i = rand1
if (i == 1){
document.gallery.previous.value=" ";}
else {
document.gallery.previous.value="Previous";}
if (i == 6){
document.gallery.next.value=" ";}
else {
document.gallery.next.value="Next";}
}
function firstimg(){
i = 1
document.img.src = images[i];
document.gallery.previous.value=" ";
document.gallery.next.value="Next"
}
function lastimg(){
i = 6
document.img.src = images[i];
document.gallery.next.value=" "
document.gallery.previous.value="Previous"
}
// -- End Hiding Here -->
</SCRIPT>
</HEAD>
<BODY style="MARGIN: 15px 10px; BACKGROUND: #000000" text=#000000>
<DIV id=maindiv1 align=center><DIV id=maindiv2 style="WIDTH: 746px; POSITION: relative">
<TABLE style="POSITION: relative" id=maintable border=0 cellSpacing=0 cellPadding=0 align=center>
<TBODY>
<TR>
<TD>
<TABLE style="BORDER-COLLAPSE: collapse; BACKGROUND: none transparent scroll repeat 0% 0%" border=0 cellSpacing=0 borderColor=#000000 width=740 align=left height=740>
<TBODY>
<TR>
<TD vAlign=top align=left>
<TABLE style="BORDER-COLLAPSE: collapse; WIDTH: 730px; BACKGROUND: none transparent scroll repeat 0% 0%; HEIGHT: 132px" border=0 cellSpacing=0 borderColor=#000000 width=730>
<TBODY>
<TR>
<TD style="BACKGROUND: #0000ff" vAlign=top align=left>
<P align=center>
<FONT color=#ffffff> BANNER</FONT></FORM></P></TD></TR></TBODY></TABLE>
<TABLE style="BORDER-COLLAPSE: collapse; WIDTH: 728px; BACKGROUND: none transparent scroll repeat 0% 0%; HEIGHT: 585px" border=0 cellSpacing=0 borderColor=#000000 width=728>
<TBODY>
<TR>
<TD style="BACKGROUND: #007236" vAlign=top width="15%" align=left>
<P align=center> </P>
<P align=center><FONT color=#ffffff>REKLAMER</FONT></P></TD>
<TD vAlign=top align=left>
<P align=center> </P>
<P align=center> <IMG border=0 name=img src="http://doonyellowpages.com/plog-content/thumbs/funny/funny/large/13-funny-cat-ninja.jpg"> </P>
<P align=center>
<form name="gallery">
<input type=button value="Previous" name="previous" onClick="previmg();">
<input type=button value="First" name="first" onClick="firstimg();">
<input type=button value="Random" name="random" onClick="pickrand();">
<input type=button value="Last" name="last" onClick="lastimg();">
<input type=button value="Next" name="next" onClick="nextimg();">
</form>
</P>
</P></TD>
<TD style="BACKGROUND: #007236" vAlign=top width="15%" align=left>
<P align=center> </P>
<P align=center><FONT color=#ffffff>REKLAMER</FONT></P></TD></TR></TBODY></TABLE>
<TABLE style="BORDER-COLLAPSE: collapse; WIDTH: 731px; BACKGROUND: none transparent scroll repeat 0% 0%; HEIGHT: 131px" border=0 cellSpacing=0 borderColor=#000000 width=731>
<TBODY>
<TR>
<TD style="BACKGROUND: #0000ff" vAlign=top align=left>
<P align=center> </P>
<P align=center><FONT color=#ffffff>BANNER</FONT></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</DIV></DIV>
</BODY>