klofisch Posted August 19, 2006 Share Posted August 19, 2006 Hello,I tried to use the following script. I think i got it from php-resource.netThe problem is, i want to open the images in a popup by Javascript.I change this Line[code] <a href='$current_dir$pic' ><img src='image_resize.php?i=$d$pic&w=$w&h=$h' alt='$pic' />[/code]to this[code]<a href='$current_dir$pic' onClick="return popup(this,790,651)"><img src='image_resize.php?i=$d$pic&w=$w&h=$h' alt='$pic' />[/code]but without any success:What i need to do?FULL CODE[code]<?echo '<h1>Photo Gallery: '.$title.'</h1>';//-------------------------------- Directory Navigation -----------------------------function dir_list($dir){ global $title; $dlist = array(); if ($hdir = opendir('./'.$dir)) { while ($obj = readdir($hdir)) { if (((preg_match("/^./",$obj)==0) && (!eregi('^(.*).[code=php:0]$', $obj))) && is_dir($dir.$obj)) //if(is_dir($dir.$obj)) $dlist[] = $obj; } closedir($hdir); } else die('Cannot list files for ' . $dir); asort($dlist); echo "<div id='dirnav'><ul>\n<li>Folders:</li>\n"; echo "<li> <a href='?'>$title » </a></li>\n"; $dirtree = explode("/", $_GET['d']); // parse directory tree from passed "d" if(!$_GET['d']) array_shift($dirtree); // remove redundant "." directory from tree foreach ($dirtree as $dirsub) { echo "<li> <a href='?d=$dirparent$dirsub'>$dirsub » </a></li>\n"; $dirparent .= $dirsub.'/'; } foreach ($dlist as $link) { echo "<li><a href='?d=$dir$link'>[$link]</a></li>\n"; } echo "</ul>\n</div>\n";}//-------------------------------------Get image file size ----------------------------------function getfilesize($size){ $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size > 1024; $i++) { $size /= 1024; } return round($size, 2).$units[$i];}//-------------------------------------Set which folder we are viewing----------------if($_GET['d']){ $d = $_GET['d'].'/'; $dd = 'd='.$_GET['d'].'&'; // for use in passing to URL strings $current_dir .= $d;} opendir($current_dir);if ($show_folders) dir_list($current_dir);//--------------------------------------- Create list of Images ------------------------$list = array();if ($dir = opendir('./'.$current_dir)){ while ($file = readdir($dir)) { //if((is_file($file)) && ((!eregi('^(.*).[code=php:0]$', $file)) && (!eregi('^(.htaccess)$', $file)))) // find all JPG, PNG or GIF images if (eregi('^(.+.(((j|J)(p|P)(g|G))|((g|G)(i|I)(f|F))|((p|P)(n|N)(g|G))))$', $file)) $list[] = $file; } closedir($dir);}asort($list); // sort alpha$numtotal = count($list); //total number of thumbsif ($thumb){ $s = 0; while($s < $thumb) { array_shift($list); $s++; }}$numremain = count($list); // total remaining thumbs//-------------------------------------- Create Thumbnails and Gallery ------------------foreach ($list as $pic){ $fp = $current_dir.$pic; if($i < $thumb+$limit) { //echo "<p class='thumb'><tt><a href='$current_dir$pic'><img src='tn/$pic' alt='$pic' /><br />$pic</a> - [".getfilesize(filesize($fp))."]</tt></p>\n"; $image = $currentdir.$pic; $i_size = getfilesize(filesize($fp)); $i_area = getimagesize($fp); $i_width = $i_area[0]; $i_height = $i_area[1]; //$i_mtime = date("d F Y ", filemtime($fp)); if ($hide_extension) $extensions = array(".jpg", ".JPG", ".gif", ".GIF", ".png", ".PNG"); if ($show_name) $name = str_replace($extensions, '', $pic); echo "<p class='thumb'> <tt> <a href='$current_dir$pic' ><img src='image_resize.php?i=$d$pic&w=$w&h=$h' alt='$pic' /><br /> $name<br /></a>\n"; if($idim) echo " [$i_width x $i_height]"; if($idim && $isize) echo " - "; if ($isize) echo " [$i_size]"; echo " <br /> </tt> </p>\n"; $i++; }}//---------------------------------------Page Navigation -----------------------------$page = 0;if(!$pg) $pg = 1;echo "<div id='nav'>\n<ul>\n";if($thumb > 0) echo "<li><a class='prev' href='?".$dd."pg=".($pg-1)."'>« Prev $limit</a></li>\n";else echo "<li><div class='prev'>« Prev $limit</div></li>";while($page*$limit < $numtotal){ $page ++; unset($cur); if($page == $pg) { $cur = ' class="current"'; } echo "<li$cur><a class='page' href='?".$dd."pg=$page'>[".($page)."]</a></li>\n";}if($numremain > $limit) echo "<li><a class='next' href='?".$dd."pg=".($pg+1)."'>Next $limit »</a></li>\n";else echo "<li><div class='next'>Next $limit »</div></li>\n";?>[/code] Quote Link to comment Share on other sites More sharing options...
youneek Posted April 15, 2007 Share Posted April 15, 2007 Wouldn't you need something like the below in your header?[code]<SCRIPT TYPE="text/javascript"><!--function popup(mylink, windowname){if (! window.focus)return true;var href;if (typeof(mylink) == 'string') href=mylink;else href=mylink.href;window.open(href, windowname, 'width=400,height=200,scrollbars=yes');return false;}//--></SCRIPT>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.