ezrapound Posted December 22, 2013 Share Posted December 22, 2013 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 More sharing options...
HartleySan Posted December 22, 2013 Share Posted December 22, 2013 Do any JavaScript errors show up in the browser console? 1 Link to comment Share on other sites More sharing options...
ezrapound Posted December 23, 2013 Author Share Posted December 23, 2013 create_window is not defined javascript:create_window('laptop.jpeg',225,%20225) Link to comment Share on other sites More sharing options...
HartleySan Posted December 23, 2013 Share Posted December 23, 2013 That means that the browser cannot find the create_window function anywhere in your JS. Where is that function definition in your code? Link to comment Share on other sites More sharing options...
ezrapound Posted December 24, 2013 Author Share Posted December 24, 2013 OOPS! my function was in the wrong directory. The message means EXACTLY what it says. Link to comment Share on other sites More sharing options...
HartleySan Posted December 24, 2013 Share Posted December 24, 2013 Cool. Glad you figured it out. Link to comment Share on other sites More sharing options...
Recommended Posts