Pop Up Windows problem

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Pop Up Windows problem

Postby jcafaro10 » 12. June 2008 17:12

I'm trying to get a popup menu to work but I'm having php errors. The error is Error 404 , Object not found. Here is my code. It finds the image in the $dir and correctly lists it so I know that thats not the problem. But somewhere between when I click the link and it tries to make a popup window, something goes wrong. Perhaps there's a problem with the create_window function (javascript)?

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
   <script language="JavaScript">
   <!-- // Hide from old browsers.
   // Make a pop-up window function:
   function create_window (image, width, height) {
      // Add some pixels to the width and height:
      width = width + 10;
      height = height + 10;
      // If the window is already open,
      // resize it to the new dimensions:
      if (window.popup && !window.popup.closed) {
         window.popup.resizeTo(width, height);
      // Set the window properties:
      var specs = "location=no, scrollbars=no, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=" + width + ", height=" + height;
      // Set the URL:
      var url = "show_image.php?image=" + image;
      // Create the pop-up window:
      popup = window.open(url, "ImageWindow", specs);
   } // End of function.
<p>Click on an image to view it in a separate window.</p>
<table align="center" cellspacing="5" cellpadding="5" border="1">
      <td align="center"><b>Image Name</b></td>
      <td align="center"><b>Image Size</b></td>
<?php # Script 10.4 - images.php
// This script lists the images in the uploads directory.

$dir = '../../uploads'; // Define the directory to view.

$files = scandir($dir); // Read all the images into an array.

// Display each image caption as a link to the JavaScript function:
foreach ($files as $image) {

   if (substr($image, 0, 1) != '.') { // Ignore anything starting with a period.
      // Get the image's size in pixels:
      $image_size = getimagesize ("$dir/$image");
      // Calculate the image's size in kilobytes:
      $file_size = round ( (filesize ("$dir/$image")) / 1024) . "kb";
      // Make the image's name URL-safe:
      $image = urlencode($image);
      // Print the information:
      echo "\t<tr>
\t\t<td><a href=\"javascript:create_window('$image',$image_size[0],$image_size[1])\">$image</a></td>
   } // End of the IF.
} // End of the foreach loop.
Posts: 15
Joined: 16. May 2008 05:43

Postby jcafaro10 » 12. June 2008 17:18

Posts: 15
Joined: 16. May 2008 05:43

Return to XAMPP for Windows

Who is online

Users browsing this forum: alex_drastico and 73 guests