webForumDet fria alternativet

visa bilder med en popup!

JavaScript

3 svar · 331 visningar · startad av dea

Medlem sedan dec. 2002387 inlägg
Frågan#1

Jag har två php sidor som jag använder för att visa bilder.
thumbs.php och show.php
i thumbs.php så visas alla thumbs från en mapp - trycker man på en bild så kommer man till show.php

Jag skulle vilja att show.php kom upp i ett popupfönster istället.
Alla funktioner hämtas från en functions.inc

thumbs.php

function show_thumbs($cols, $th_width, $th_height, $cellpadding, 
                     $cellspacing, $perpage)
{
  $dir = $_GET["dir"];
  $tot = count_files($dir);
  if (isset($_GET["page"])) {
    $page = $_GET["page"];
  }  
  if (isset($_GET["img"])) {
    $img = $_GET["img"];
  }
  global $showfilename;
  global $hidefilenameext;
  
  if ($page == NULL) {
    $page = ceil($img  / $perpage);
  }
  
  echo "<div style='text-align: center'>";
  echo "<table border='0' cellpadding='$cellpadding' 
        cellspacing='$cellspacing' align='center'>\n";
  echo "<tr>\n";
         
  $filelist = list_files("./$dir/thumbs");
  $n = 1;
  
  $end = min(($page * $perpage), sizeof($filelist));

  for ($i = (($page - 1) * $perpage);  $i < $end; $i++) 
  {
    echo "<td align='center'>\n";    
    echo "<table border='0' cellspacing='1' cellpadding='0' 
          bgcolor='#F8F8F8'>\n";
    echo "<tr><td>\n";
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
         "&page=$page'>\n";
    echo "<img src='$dir/thumbs/$filelist[$i]' width='$th_width' 
               height='$th_height' border='0'><br>\n";
    echo "</a>\n";
    echo "</td></tr>\n";
    echo "</table>\n";
    
    if ($showfilename) 
    {
      if ($hidefilenameext) {
        echo "<small>".substr($filelist[$i], 0, strrpos($filelist[$i], '.'))."</small>";
      }
      else
      {
        echo "<small>$filelist[$i]</small>";
      }     
    }
    
    echo "</td>\n"; 

    if (($n % $cols) == 0 && ($n != $perpage)) 
    {
      echo "</tr>";
      echo "<tr align='center'>";
    }
    
    $n++;
  }
  echo "</tr>\n";    
  echo "</table>";
 
  // We need to show thumbs in more than one page
  if (sizeof($filelist) > $perpage) {
    echo ("Page:&nbsp;");
    
    for ($j = 1; $j <= ceil(sizeof($filelist) / $perpage); $j++) {
     echo ("<a href='thumbs.php?dir=$dir&page=".$j."'>");
     
     // Current page   
     if ($page == $j) {
       echo "<b>".$j."</b>";
     }
     else 
     {
       echo $j;
     } 
      
     echo "</a>";
     echo ("&nbsp;&nbsp;");
    }
  
    echo "<br><br>";  
  }

  echo "<a href='index.php'>Album</a>&nbsp;"; 
  
  echo "</div>";
 }

show.php

function show_picture()
{
  $dir = $_GET["dir"];
  $tot = $_GET["tot"];
  $img = $_GET["img"];

  echo "<div style='text-align: center'>";
  echo "<big>\n";
  
  if ($img  > 1)
  {
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'>&lt;&lt;</a>"; 
  }

  echo "&nbsp;&nbsp;&nbsp\n";
  echo "</big>\n";
  echo "<b>".$img."</b> of ".$tot; 
  echo "&nbsp;&nbsp;&nbsp\n";
  echo "<big>\n";

  if ($img < $tot)
  {
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>&gt;&gt;</a>"; 
  }

  echo "</big>\n";
  echo "<br><br>\n"; 
  
  echo "<table border='0' cellspacing='1' cellpadding='0' 
               bgcolor='#F8F8F8' align='center'>\n";
  echo "<tr><td>\n";
  echo "<a href='thumbs.php?dir=$dir&img=$img'>"; 
  echo "<img src='$dir/".search_file("./$dir", $img)."' border=0 
        onLoad='resize(this);' name=foto 
        alt='Click to go to thumbnails page.'>";
  echo "</a>";        
  echo "</td></tr>\n";
  echo "</table>\n";

  
  echo "<br><br>\n"; 
  echo "<big>\n";
  
  if ($img > 1)
  {
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img - 1)."'>&lt;&lt;</a>"; 
  }
  
  echo "&nbsp;&nbsp;&nbsp\n";
  
  if ($img  < $tot)
  {
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($img + 1)."'>&gt;&gt;</a>"; 
  }

  echo "</big>\n";
  echo "<br><br>\n"; 

  echo "<a href='index.php'>Album</a>&nbsp; - &nbsp;"; 
  echo "<a href='thumbs.php?dir=$dir&img=$img'>Bilder</a>";  
    
  echo "<br><br>\n"; 
  
  echo "</div>"; 
}

?>
Medlem sedan dec. 2002387 inlägg
#2

Jag undrar om det "bara" är att lägga in ett Javascript i

echo "<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
"&page=$page'>\n";

typ:

<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
"&page=$page' [B][blue][red]onclick="openwin(this.href); return false;[/red][/blue][/B]>\n";

och en funktion någonstans i

function show_thumbs($cols, $th_width, $th_height, $cellpadding, 
                     $cellspacing, $perpage)
{
  $dir = $_GET["dir"];
  $tot = count_files($dir);
  if (isset($_GET["page"])) {
    $page = $_GET["page"];
  }  
  if (isset($_GET["img"])) {
    $img = $_GET["img"];
  }
  global $showfilename;
  global $hidefilenameext;
  
  if ($page == NULL) {
    $page = ceil($img  / $perpage);
  }
  
  echo "<div style='text-align: center'>";
  echo "<table border='0' cellpadding='$cellpadding' 
        cellspacing='$cellspacing' align='center'>\n";
  echo "<tr>\n";
         
  $filelist = list_files("./$dir/thumbs");
  $n = 1;
  
  $end = min(($page * $perpage), sizeof($filelist));

  for ($i = (($page - 1) * $perpage);  $i < $end; $i++) 
  {
    echo "<td align='center'>\n";    
    echo "<table border='0' cellspacing='1' cellpadding='0' 
          bgcolor='#F8F8F8'>\n";
    echo "<tr><td>\n";
    echo "<a href='show.php?dir=$dir&tot=$tot&img=".($i + 1).
         "&page=$page'>\n";
    echo "<img src='$dir/thumbs/$filelist[$i]' width='$th_width' 
               height='$th_height' border='0'><br>\n";
    echo "</a>\n";
    echo "</td></tr>\n";
    echo "</table>\n";
    
    if ($showfilename) 
    {
      if ($hidefilenameext) {
        echo "<small>".substr($filelist[$i], 0, strrpos($filelist[$i], '.'))."</small>";
      }
      else
      {
        echo "<small>$filelist[$i]</small>";
      }     
    }
    
    echo "</td>\n"; 

    if (($n % $cols) == 0 && ($n != $perpage)) 
    {
      echo "</tr>";
      echo "<tr align='center'>";
    }
    
    $n++;
  }
  echo "</tr>\n";    
  echo "</table>";
 
  // We need to show thumbs in more than one page
  if (sizeof($filelist) > $perpage) {
    echo ("Page:&nbsp;");
    
    for ($j = 1; $j <= ceil(sizeof($filelist) / $perpage); $j++) {
     echo ("<a href='thumbs.php?dir=$dir&page=".$j."'>");
     
     // Current page   
     if ($page == $j) {
       echo "<b>".$j."</b>";
     }
     else 
     {
       echo $j;
     } 
      
     echo "</a>";
     echo ("&nbsp;&nbsp;");
    }
  
    echo "<br><br>";  
  }

  echo "<a href='index.php'>Album</a>&nbsp;"; 
  
  echo "</div>";
 }
Medlem sedan dec. 2002387 inlägg
#3

Jag har ordnat det på ett annat sätt men skulle gärna veta om det går att göra som jag trodde!?

Medlem sedan apr. 20031 660 inlägg
#4

HEJ!

Jo, det är så jag skulle gjort, med this.href (för att kunna öppna nya fönstret som man vill) och return false (för att inte basfönstret ska hoppa upp), om jag behöver öppna ett litet fönster, oavsett språk sidan är gjord i.

Reservation alltså för att php/andra språk skulle ha egna trix, men så kan det väl inte vara, det är ju ett klientspråk som behövs?

255 ms totalt · 4 externa anrop · v20260731065814-full.1dc6f849
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
115 ms — ändringar (db)