Jump to content
Larry Ullman's Book Forums

Ch11 No Output From Images.Php


Recommended Posts

When I hover on a filename, I see the javascript reference in the bottom bar of the firefox screen, but when I click on it nothing happens.

php looks like this:

<!DOCTYPE html PUBLIC
  "-//W3C//   DTD XHTML 1.0  Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/
  xhtml1-transitional.dtd">
<html xmlns="http://w3.org/1999/xhtml"
  xml:lang="en" lang="en">
<head>
<title>Images</title>
<script type="text/javascript" charset="utf-8" src="js/function.js">
</script>
<link rel="stylesheet" href=
  "style.css" type = "text/css" media = "all" />
<meta http-equiv="content-type" content = "text/html; charset=utf-8" />
</head>                                

<body>
<p>Click on an image name to view it in a separate window.</p>
<ul>

<?php # script 11.4  - images.php Written Dec 22, 2013
$dir = '../../../uploads';
$files = scandir($dir);

foreach ($files as $image) {
  if (substr($image, 0, 1) != '.') {                        // check for non-dotted (system) files
    $image_size = getimagesize ("$dir/$image");
  $image_name = urlencode($image);
  echo "<li><a href=\"javascript:create_window('$image_name',$image_size[0], $image_size[1])\">$image </a></li>\n";

  }                                                        // end of IF
}  
?>                                                    
</ul>

</body>
</html>

Generated code in images.php looks like this:

<!DOCTYPE html PUBLIC
"-//W3C// DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/
xhtml1-transitional.dtd">

<html xmlns="http://w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<title>Images</title>
<script type="text/javascript" charset="utf-8" src="js/function.js">
</script>
<link rel="stylesheet" href=
"
style.css" type = "text/css" media = "all" />
<meta http-equiv="content-type" content = "text/html; charset=utf-8" />
</head>

<body>
<p>Click on an image name to view it in a separate window.</p>
<ul>

<li><a href="javascript:create_window('laptop.jpeg',225, 225)">laptop.jpeg </a></li>
<li><a href="javascript:create_window('laptop2.jpeg',225, 225)">laptop2.jpeg </a></li>
<li><a href="javascript:create_window('neuman.jpeg',222, 227)">neuman.jpeg </a></li>

</ul>

</body>
</html>

Link to comment
Share on other sites

 Share

×
×
  • Create New...