Jump to content

open new window


tgribble

Recommended Posts

hi there

 

i have a basic image gallery. it displays smaller thumbnails in a folder and when you click on them it displays a larger image.

 

how can i make the larger image open in a seperate window of 640x480 when the thumbnail is clicked?

 

thanks

 

here is the code:

 

<?php

include('connect.php');

 

$images = "images/"; # Location of small versions

$big    = "big/"; # Location of big versions (assumed to be a subdir of above)

$cols  = 4; # Number of columns to display

 

if ($handle = opendir($images)) {

  while (false !== ($file = readdir($handle))) {

      if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {

          $files[] = $file;

      }

  }

  closedir($handle);

}

 

$colCtr = 0;

echo '<table width="50%" cellspacing="3" align=center ><tr>';

foreach($files as $file)

{

  if($colCtr %$cols == 0)

    echo '</tr><tr><td colspan="10" ></td></tr><tr>';

  echo '<td ><a href="' . $images . $big . $file . '" ><img src="' . $images . $file . '" /></a></td>';

  $colCtr++;

}

echo '</table>' . "\r\n";

?>

Link to comment
https://forums.phpfreaks.com/topic/236693-open-new-window/
Share on other sites

you gotta use Javascript.

 

for instance...

<script type="text/javascript">
function newImageWindow(){
//some javascript function that opens a popup window here
}
</script>
<?php
//build your link dynamically with the function in it
echo '<a href="#" onclick="newImageWindow();"><img src="myimage.jpg"></a>
?>

 

something like that is what you need.

Link to comment
https://forums.phpfreaks.com/topic/236693-open-new-window/#findComment-1216734
Share on other sites

ok ,

 

i am up to this stage, but how do i make the clicked on image display in the popup window?

 

thanks

 

 

<html>

<head>

<title>JavaScript Popup Example 3</title>

</head>

<script type="text/javascript">

function poponload()

{

    testwindow = window.open("", "mywindow", "location=1,status=1,scrollbars=1,width=640,height=480");

    testwindow.moveTo(200, 200);

}

</script>

<body onclick="javascript: poponload()">

 

<h1><center>The Jewels</center></h1>

 

<?php

 

 

$images = "images/"; # Location of small versions

$big    = "big/"; # Location of big versions (assumed to be a subdir of above)

$cols  = 4; # Number of columns to display

 

if ($handle = opendir($images)) {

  while (false !== ($file = readdir($handle))) {

      if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {

          $files[] = $file;

      }

  }

  closedir($handle);

}

 

$colCtr = 0;

echo '<table width="50%" cellspacing="3" align=center ><tr>';

foreach($files as $file)

{

  if($colCtr %$cols == 0)

    echo '</tr><tr><td colspan="10" ></td></tr><tr>';

 

  echo '<td ><a href="' . $images . $big . $file . '" ><img src="' . $images . $file . '" /></a></td>';

  $colCtr++;

}

echo '</table>' . "\r\n";

?>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/236693-open-new-window/#findComment-1216755
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.