Avatar billede flashnoob Nybegynder
03. august 2005 - 21:39 Der er 22 kommentarer og
1 løsning

Slideshow med link på hvert billede?

Hej

Jeg har fundet det javascript du kan se længere nede i indlæget.

Det jeg gerne vil er at sætte et link på hver billede, således at man kan se billedet i stor format. Jeg kan godt sætte ét link på, men det er det samme link på hvert billede så... kan man sætte et forskelligt link på hvert billede?

(Se scriptet i aktion her: http://www.codelifter.com/main/javascript/slideshow4_show.html )



===== Javascript koden =====

<html>

<head>

<title>PushButton SlideShow</title>

<!--
Set up the caption font in the following style.
Also set the styles for the controls.
Place the style script in the head of the page.
//-->

<style>
.Caption {
font-family: Arial;
font-weight: normal;
font-size:  12pt;
color:      #FF3300; }

A.Controls:link    { color:#666666;
                    text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:visited { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:active  { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:hover  { color:#00FF00; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }

</style>

<!--
Place the following script in the head of the page.
Follow the set-up instructions within the script.
//-->

<script>

// (C) 2003 by CodeLifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 2;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var showHot = false;      // don't change this

// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

Caption[1]  = "This is the first caption.";
Caption[2]  = "This is the second caption.";
Caption[3]  = "This is the third caption.";
Caption[4]  = "This is the fourth caption.";
Caption[5]  = "This is the fifth caption.";
Caption[6]  = "This is the sixth caption.";
Caption[7]  = "This is the seventh caption.";
Caption[8]  = "This is the eighth caption.";
Caption[9]  = "This is the ninth caption.";
Caption[10] = "This is the tenth caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 0;
var pss = Picture.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function control(how){
if (showHot){
if (how=="H") jss = 1;
if (how=="F") jss = jss + 1;
if (how=="B") jss = jss - 1;
if (jss > (pss)) jss=1;
if (jss < 1) jss = pss;
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
if (document.getElementById) document.getElementById("CaptionBox").innerHTML= Caption[jss];
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
}}

</script>

</head>

<!--
Add onload='showHot=true;' to the body tag.  This is
needed to prevent false object calls while the page
is loading. Optional: If you are using this in a
popup, as in this demo, adding self.focus() to the
onload event in the body tag will bring the popup
to the front each time it is loaded [recommended].
//-->

<body onload='showHot=true;self.focus();' bgcolor=#000000 link="#FF0000" vlink="#FF0000" alink="#FF0000">

<!--
The following table holds the images, captions, and controls.
Place the table in your page where you want the slideshow
to appear.  Follow the instructions for each table cell.
//-->

<div align="center">
  <center>

<table border=0 cellpadding=10 cellspacing=0>
  <tr>
    <!--
    The next table cell holds the images.
    Set cell and image width and height the same.
    The img src must have name=PictureBox in its
    tag.  Often, the first image in the Picture
    array in the script is used here; but you
    may also use a different, introductory image
    as we have here, since this image is shown
    only on start-up.
    //-->
    <td width=350 height=280 colspan="3">
    <img src=Nebula00.gif name=PictureBox width=350 height=280>
    </td>
  </tr>
  <tr>
    <!--
    The next table cell holds the captions.
    This table cell must have id=CaptionBox and
    class=Caption in its tag. The default caption
    shows whilst loading in all browsers; NS4
    will show only the default caption, throughout.
    //-->
    <td id=CaptionBox class=Caption align=center colspan="3">
    This is the default caption.
    </td>
  </tr>
    <!--
    The following three cells contain the controls.
    Each of the control a href's must contain class=
    Controls, to attach the styles (see top of script).
    To dress this up a bit, you can of course substitute
    <img src> images for the text in the links.
    //-->
  <tr>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('B');">< <</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('H');">| | |</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('F');"><b>> ></b></a>
    </td>
  </tr> 
</table>

  </center>
</div>

</body>

</html>
Avatar billede softspot Forsker
03. august 2005 - 22:43 #1
prøv med dette:

<html>

<head>

<title>PushButton SlideShow</title>

<!--
Set up the caption font in the following style.
Also set the styles for the controls.
Place the style script in the head of the page.
//-->

<style>
.Caption {
font-family: Arial;
font-weight: normal;
font-size:  12pt;
color:      #FF3300; }

A.Controls:link    { color:#666666;
                    text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:visited { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:active  { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:hover  { color:#00FF00; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }

</style>

<!--
Place the following script in the head of the page.
Follow the set-up instructions within the script.
//-->

<script>

// (C) 2003 by CodeLifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 2;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var showHot = false;      // don't change this

// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

Caption[1]  = "This is the first caption.";
Caption[2]  = "This is the second caption.";
Caption[3]  = "This is the third caption.";
Caption[4]  = "This is the fourth caption.";
Caption[5]  = "This is the fifth caption.";
Caption[6]  = "This is the sixth caption.";
Caption[7]  = "This is the seventh caption.";
Caption[8]  = "This is the eighth caption.";
Caption[9]  = "This is the ninth caption.";
Caption[10] = "This is the tenth caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 0;
var pss = Picture.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function control(how){
if (showHot){
if (how=="H") jss = 1;
if (how=="F") jss = jss + 1;
if (how=="B") jss = jss - 1;
if (jss > (pss)) jss=1;
if (jss < 1) jss = pss;
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
document.getElementById("PictureLink").href = preLoad[jss].src;
if (document.getElementById) document.getElementById("CaptionBox").innerHTML= Caption[jss];
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
}}

</script>

</head>

<!--
Add onload='showHot=true;' to the body tag.  This is
needed to prevent false object calls while the page
is loading. Optional: If you are using this in a
popup, as in this demo, adding self.focus() to the
onload event in the body tag will bring the popup
to the front each time it is loaded [recommended].
//-->

<body onload='showHot=true;self.focus();' bgcolor=#000000 link="#FF0000" vlink="#FF0000" alink="#FF0000">

<!--
The following table holds the images, captions, and controls.
Place the table in your page where you want the slideshow
to appear.  Follow the instructions for each table cell.
//-->

<div align="center">
  <center>

<table border=0 cellpadding=10 cellspacing=0 ID="Table1">
  <tr>
    <!--
    The next table cell holds the images.
    Set cell and image width and height the same.
    The img src must have name=PictureBox in its
    tag.  Often, the first image in the Picture
    array in the script is used here; but you
    may also use a different, introductory image
    as we have here, since this image is shown
    only on start-up.
    //-->
    <td width=350 height=280 colspan="3">
    <a id="PictureLink" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox width=350 height=280 border=0></a>
    </td>
  </tr>
  <tr>
    <!--
    The next table cell holds the captions.
    This table cell must have id=CaptionBox and
    class=Caption in its tag. The default caption
    shows whilst loading in all browsers; NS4
    will show only the default caption, throughout.
    //-->
    <td id=CaptionBox class=Caption align=center colspan="3">
    This is the default caption.
    </td>
  </tr>
    <!--
    The following three cells contain the controls.
    Each of the control a href's must contain class=
    Controls, to attach the styles (see top of script).
    To dress this up a bit, you can of course substitute
    <img src> images for the text in the links.
    //-->
  <tr>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('B');">< <</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('H');">| | |</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('F');"><b>> ></b></a>
    </td>
  </tr> 
</table>

  </center>
</div>

</body>

</html>
Avatar billede flashnoob Nybegynder
03. august 2005 - 23:01 #2
Jamen det er jo smukt!!! :) J
eg sad lige og kikkede på hvor du havde lavet om på koden.. men synes det er pænt uoverskueligt. Jeg ville så lige ændre linket så den kunne linke ind i en mappe eks. /blabla/Nebula01.jpg, men fik igen kun linket første billede. Hvor skal koden ændres henne? Hvis det kan lade sig gøre :)
Avatar billede softspot Forsker
03. august 2005 - 23:07 #3
Jeg har faktisk kun tilføjet et par linier:

document.getElementById("PictureLink").href = preLoad[jss].src;

og i HTML-koden:

    <a id="PictureLink" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox width=350 height=280 border=0></a>


Det skal ændres i det array som ligger i toppen af siden. Det der ser således ud:

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';

Her skal du bare ændre stien til de enkelte billeder. Noget i stil med:

Picture[1]  = 'blah/Nebula01.jpg';
Picture[2]  = 'blah/Nebula02.jpg';
Picture[3]  = 'blah/Nebula03.jpg';
Picture[4]  = 'blah/Nebula04.jpg';
Picture[5]  = 'blah/Nebula05.jpg';
Picture[6]  = 'blah/Nebula06.jpg';
Picture[7]  = 'blah/Nebula07.jpg';
Picture[8]  = 'blah/Nebula08.jpg';
Picture[9]  = 'blah/Nebula09.jpg';
Picture[10] = 'blah/Nebula10.jpg';
Avatar billede softspot Forsker
03. august 2005 - 23:08 #4
Du kan naturligvis også bare ændre denne linie:

preLoad[iss].src = Picture[iss];}

til

preLoad[iss].src = 'blah/' + Picture[iss];}
Avatar billede softspot Forsker
03. august 2005 - 23:09 #5
...og så lade

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';

være i fred :)
Avatar billede flashnoob Nybegynder
03. august 2005 - 23:10 #6
Okay! Du er sq en knag! :) Pointsne er dine. Har du mod på at hjælpe med et andet javascript spørgsmål, med den samme kode som her. Du får naturligvis flere points :)
Avatar billede flashnoob Nybegynder
03. august 2005 - 23:10 #7
Ja, det er jo lettere :)
Avatar billede softspot Forsker
03. august 2005 - 23:16 #8
Ind over! - til samme pris (altså ikke flere points end dem du giver mig for dette spm. - det er fint nok) ;)
Avatar billede flashnoob Nybegynder
03. august 2005 - 23:22 #9
Cool :)
Okay.. jeg vil gerne have 3 billeder i stedet kun ét billede, således at når der klikkes på højre pil kommer de næste 3 billeder osv.. Kan det lade sig gøre? :)
Avatar billede softspot Forsker
03. august 2005 - 23:31 #10
Det skulle jeg da mene (de alt kan lade sig gøre for den som bærer viljen i jernet... øøøh... hjertet).

Det komplicerer dog rutinen noget, da der så skal tages højde for at der ikke nødvendigvis er et antal billeder som er deleligt med 3 og dermed ikke skal vises billeder i alle 3 billederammer (specielt i starten og slutningen af listen).

Jeg prøver lige at fedte med noget kode, så vender jeg tilbage...
Avatar billede flashnoob Nybegynder
03. august 2005 - 23:35 #11
lol - ja, viljen i jernet hehe
Cool! Det ville være fedest med 3 billeder, men 2 / 4 går også :)
Avatar billede softspot Forsker
04. august 2005 - 00:33 #12
Prøv lige at teste denne her (jeg har selv surfet lidt igennem den for at se om jeg kunne finde nogle store BUGS, men synes den fungerer nogenlunde).

Den surfer igennem de billeder der er og når den kommer til slutningen af listen aligner den så der også er 3 billeder på det sidste skærmbillede, selvom to af dem godt kan være de samme som var på forrige billeder (det er for at bibeholde formatet at skærmbilledet med 3 billeder på alle). Hvis du så trykker på frem igen vil den starte fra de første 3 billeder igen. Det samme gør sig gældende i den anden retning (blot med omvendt fortegn naturligvis :)).

<html>

<head>

<title>PushButton SlideShow</title>

<!--
Set up the caption font in the following style.
Also set the styles for the controls.
Place the style script in the head of the page.
//-->

<style>
.Caption {
font-family: Arial;
font-weight: normal;
font-size:  12pt;
color:      #FF3300; }

A.Controls:link    { color:#666666;
                    text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:visited { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:active  { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:hover  { color:#00FF00; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }

</style>

<!--
Place the following script in the head of the page.
Follow the set-up instructions within the script.
//-->

<script>

// (C) 2003 by CodeLifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 2;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var showHot = false;      // don't change this

// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

Caption[1]  = "This is the first caption.";
Caption[2]  = "This is the second caption.";
Caption[3]  = "This is the third caption.";
Caption[4]  = "This is the fourth caption.";
Caption[5]  = "This is the fifth caption.";
Caption[6]  = "This is the sixth caption.";
Caption[7]  = "This is the seventh caption.";
Caption[8]  = "This is the eighth caption.";
Caption[9]  = "This is the ninth caption.";
Caption[10] = "This is the tenth caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 0;
var pss = Picture.length - 1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
    preLoad[iss] = new Image();
    preLoad[iss].src = Picture[iss];
}

function control(how){
    if (showHot){
        if (how=="H") jss = 1;
        if (how=="F" && jss != 0) {
            jss = (jss == pss - 2) ? 1 : (jss + 1 <= pss && jss + 3 >= pss) ? pss - 2 : jss + 3;
        }
        if (how=="F" && jss == 0) jss = 1; // første klik på fremad
        if (how=="B") jss = (jss - 1 >= 1 && jss - 3 < 1) ? 1 : jss - 3;
        if (jss > (pss)) jss = 1;
        if (jss < 1) jss = pss - 2;
        if(jss > pss - 2) alert("jss = " + jss);
        if (document.all){
            document.images.PictureBox1.style.filter="blendTrans(duration=2)";
            document.images.PictureBox1.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox1.filters.blendTrans.Apply();
            document.images.PictureBox2.style.filter="blendTrans(duration=2)";
            document.images.PictureBox2.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox2.filters.blendTrans.Apply();
            document.images.PictureBox3.style.filter="blendTrans(duration=2)";
            document.images.PictureBox3.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox3.filters.blendTrans.Apply();
        }
        document.images.PictureBox1.src = preLoad[jss].src;
        document.images.PictureBox2.src = preLoad[jss+1].src;
        document.images.PictureBox3.src = preLoad[jss+2].src;
        document.getElementById("PictureLink1").href = preLoad[jss].src;
        document.getElementById("PictureLink2").href = preLoad[jss+1].src;
        document.getElementById("PictureLink3").href = preLoad[jss+2].src;
        if (document.getElementById) {
            document.getElementById("CaptionBox1").innerHTML= Caption[jss];
            document.getElementById("CaptionBox2").innerHTML= Caption[jss+1];
            document.getElementById("CaptionBox3").innerHTML= Caption[jss+2];
        }
        if (document.all) {
            document.images.PictureBox1.filters.blendTrans.Play();
            document.images.PictureBox2.filters.blendTrans.Play();
            document.images.PictureBox3.filters.blendTrans.Play();
        }
    }
    return true;
}

</script>

</head>

<!--
Add onload='showHot=true;' to the body tag.  This is
needed to prevent false object calls while the page
is loading. Optional: If you are using this in a
popup, as in this demo, adding self.focus() to the
onload event in the body tag will bring the popup
to the front each time it is loaded [recommended].
//-->

<body onload='showHot=true;self.focus();' bgcolor=#000000 link="#FF0000" vlink="#FF0000" alink="#FF0000">

<!--
The following table holds the images, captions, and controls.
Place the table in your page where you want the slideshow
to appear.  Follow the instructions for each table cell.
//-->

<div align="center">
  <center>

<table border=0 cellpadding=10 cellspacing=0 ID="Table1">
  <tr>
    <!--
    The next table cell holds the images.
    Set cell and image width and height the same.
    The img src must have name=PictureBox in its
    tag.  Often, the first image in the Picture
    array in the script is used here; but you
    may also use a different, introductory image
    as we have here, since this image is shown
    only on start-up.
    //-->
    <td width=350 height=280>
    <a id="PictureLink1" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox1 width=350 height=280 border=0></a>
    </td>
    <td width=350 height=280>
    <a id="PictureLink2" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox2 width=350 height=280 border=0></a>
    </td>
    <td width=350 height=280>
    <a id="PictureLink3" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox3 width=350 height=280 border=0></a>
    </td>
  </tr>
  <tr>
    <!--
    The next table cell holds the captions.
    This table cell must have id=CaptionBox and
    class=Caption in its tag. The default caption
    shows whilst loading in all browsers; NS4
    will show only the default caption, throughout.
    //-->
    <td id=CaptionBox1 class=Caption align=center>
    This is the default caption.
    </td>
    <td id=CaptionBox2 class=Caption align=center>
    This is the default caption.
    </td>
    <td id=CaptionBox3 class=Caption align=center>
    This is the default caption.
    </td>
  </tr>
    <!--
    The following three cells contain the controls.
    Each of the control a href's must contain class=
    Controls, to attach the styles (see top of script).
    To dress this up a bit, you can of course substitute
    <img src> images for the text in the links.
    //-->
  <tr>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('B');">< <</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('H');">| | |</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('F');"><b>> ></b></a>
    </td>
  </tr> 
</table>

  </center>
</div>

</body>

</html>
Avatar billede softspot Forsker
04. august 2005 - 00:35 #13
Ups! mangler lige at fjerne en alert i control-funktionen. Desuden fungerer den ikke med 11 billeder...
Avatar billede flashnoob Nybegynder
04. august 2005 - 00:46 #14
Du er en sand mester! Det er bare perfekt...! Er der flere tal den ikke dur med f.eks. 16, 22?
Avatar billede softspot Forsker
04. august 2005 - 00:50 #15
Hep der! Så kom der en version som gerne skulle fungere med et vilkårligt antal (håber jeg :)):

<html>

<head>

<title>PushButton SlideShow</title>

<!--
Set up the caption font in the following style.
Also set the styles for the controls.
Place the style script in the head of the page.
//-->

<style>
.Caption {
font-family: Arial;
font-weight: normal;
font-size:  12pt;
color:      #FF3300; }

A.Controls:link    { color:#666666;
                    text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:visited { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:active  { color:#666666; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }
A.Controls:hover  { color:#00FF00; text-decoration:none;
                    font-family: Arial;
                    font-size:  14pt;
                    font-weight: bold; }

</style>

<!--
Place the following script in the head of the page.
Follow the set-up instructions within the script.
//-->

<script>

// (C) 2003 by CodeLifter.com
// Free for all users, but leave in this header.

// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 3000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 2;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this
var showHot = false;      // don't change this

// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = 'Nebula01.jpg';
Picture[2]  = 'Nebula02.jpg';
Picture[3]  = 'Nebula03.jpg';
Picture[4]  = 'Nebula04.jpg';
Picture[5]  = 'Nebula05.jpg';
Picture[6]  = 'Nebula06.jpg';
Picture[7]  = 'Nebula07.jpg';
Picture[8]  = 'Nebula08.jpg';
Picture[9]  = 'Nebula09.jpg';
Picture[10] = 'Nebula10.jpg';
Picture[11] = 'Nebula11.jpg';
Picture[12] = 'Nebula12.jpg';

// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

Caption[1]  = "This is the first caption.";
Caption[2]  = "This is the second caption.";
Caption[3]  = "This is the third caption.";
Caption[4]  = "This is the fourth caption.";
Caption[5]  = "This is the fifth caption.";
Caption[6]  = "This is the sixth caption.";
Caption[7]  = "This is the seventh caption.";
Caption[8]  = "This is the eighth caption.";
Caption[9]  = "This is the ninth caption.";
Caption[10] = "This is the tenth caption.";
Caption[11] = "This is the eleventh caption.";
Caption[12] = "This is the twelfth caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 0;
var pss = Picture.length - 1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
    preLoad[iss] = new Image();
    preLoad[iss].src = Picture[iss];
}

function control(how){
    if (showHot){
        if (how=="H") jss = 1;
        if (how=="F" && jss != 0) jss = (jss == pss - 2) ? 1 : (jss + 3 <= pss && jss + 4 >= pss) ? pss - 2 : jss + 3;
        if (how=="F" && jss == 0) jss = 1; // første klik på fremad
        if (how=="B") jss = (jss - 1 >= 1 && jss - 3 < 1) ? 1 : jss - 3;
        if (jss > (pss)) jss = 1;
        if (jss < 1) jss = pss - 2;
        if (document.all){
            document.images.PictureBox1.style.filter="blendTrans(duration=2)";
            document.images.PictureBox1.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox1.filters.blendTrans.Apply();
            document.images.PictureBox2.style.filter="blendTrans(duration=2)";
            document.images.PictureBox2.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox2.filters.blendTrans.Apply();
            document.images.PictureBox3.style.filter="blendTrans(duration=2)";
            document.images.PictureBox3.style.filter="blendTrans(duration=CrossFadeDuration)";
            document.images.PictureBox3.filters.blendTrans.Apply();
        }
        document.images.PictureBox1.src = preLoad[jss].src;
        document.images.PictureBox2.src = preLoad[jss+1].src;
        document.images.PictureBox3.src = preLoad[jss+2].src;
        document.getElementById("PictureLink1").href = preLoad[jss].src;
        document.getElementById("PictureLink2").href = preLoad[jss+1].src;
        document.getElementById("PictureLink3").href = preLoad[jss+2].src;
        if (document.getElementById) {
            document.getElementById("CaptionBox1").innerHTML= Caption[jss];
            document.getElementById("CaptionBox2").innerHTML= Caption[jss+1];
            document.getElementById("CaptionBox3").innerHTML= Caption[jss+2];
        }
        if (document.all) {
            document.images.PictureBox1.filters.blendTrans.Play();
            document.images.PictureBox2.filters.blendTrans.Play();
            document.images.PictureBox3.filters.blendTrans.Play();
        }
    }
    return true;
}

</script>

</head>

<!--
Add onload='showHot=true;' to the body tag.  This is
needed to prevent false object calls while the page
is loading. Optional: If you are using this in a
popup, as in this demo, adding self.focus() to the
onload event in the body tag will bring the popup
to the front each time it is loaded [recommended].
//-->

<body onload='showHot=true;self.focus();' bgcolor=#000000 link="#FF0000" vlink="#FF0000" alink="#FF0000">

<!--
The following table holds the images, captions, and controls.
Place the table in your page where you want the slideshow
to appear.  Follow the instructions for each table cell.
//-->

<div align="center">
  <center>

<table border=0 cellpadding=10 cellspacing=0 ID="Table1">
  <tr>
    <!--
    The next table cell holds the images.
    Set cell and image width and height the same.
    The img src must have name=PictureBox in its
    tag.  Often, the first image in the Picture
    array in the script is used here; but you
    may also use a different, introductory image
    as we have here, since this image is shown
    only on start-up.
    //-->
    <td width=350 height=280>
    <a id="PictureLink1" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox1 width=350 height=280 border=0></a>
    </td>
    <td width=350 height=280>
    <a id="PictureLink2" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox2 width=350 height=280 border=0></a>
    </td>
    <td width=350 height=280>
    <a id="PictureLink3" href="Nebula00.gif">
        <img src=Nebula00.gif name=PictureBox3 width=350 height=280 border=0></a>
    </td>
  </tr>
  <tr>
    <!--
    The next table cell holds the captions.
    This table cell must have id=CaptionBox and
    class=Caption in its tag. The default caption
    shows whilst loading in all browsers; NS4
    will show only the default caption, throughout.
    //-->
    <td id=CaptionBox1 class=Caption align=center>
    This is the default caption.
    </td>
    <td id=CaptionBox2 class=Caption align=center>
    This is the default caption.
    </td>
    <td id=CaptionBox3 class=Caption align=center>
    This is the default caption.
    </td>
  </tr>
    <!--
    The following three cells contain the controls.
    Each of the control a href's must contain class=
    Controls, to attach the styles (see top of script).
    To dress this up a bit, you can of course substitute
    <img src> images for the text in the links.
    //-->
  <tr>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('B');">< <</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('H');">| | |</a>
    </td>
    <td align="center">
    <a class=Controls href="#" onClick="java script:control('F');"><b>> ></b></a>
    </td>
  </tr> 
</table>

  </center>
</div>

</body>

</html>
Avatar billede softspot Forsker
04. august 2005 - 00:55 #16
Vil du også have et svar? :)
Avatar billede flashnoob Nybegynder
04. august 2005 - 00:59 #17
Du er slet ikke til at stoppe :D Den sidste kode laver to tomme kasser med røde kryds, på plads 11 og 12, hvis man kun har 10 billeder. Men den anden kode er perfekt :D
Tusind tak for hjælpen!
Avatar billede softspot Forsker
04. august 2005 - 01:02 #18
De røde kryds kommer vel fordi du ikke har nogen billeder der hedder nebula11.jpg og nebula12.jpg... eller tager jeg fejl?
Avatar billede softspot Forsker
04. august 2005 - 01:02 #19
Takker for point :)
Avatar billede flashnoob Nybegynder
04. august 2005 - 01:05 #20
Ja, det er rigtigt. Jeg har kun 10 billeder..

Mht. points - vær's go :)
Avatar billede softspot Forsker
04. august 2005 - 01:08 #21
Du har styr på hvordan du udvider listen med billeder og tilhørende tekster, ikk'?
Avatar billede flashnoob Nybegynder
04. august 2005 - 01:11 #22
Jo, det står i teksten. :) Jeg ligger halvvejs under dynen...
tak for hjælpen endnu engang, du har været en stor hjælp!
Avatar billede softspot Forsker
04. august 2005 - 01:15 #23
Jeg er glad for at kunne hjælpe.

Godnat og sov godt :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester