SharkBait Posted October 6, 2006 Share Posted October 6, 2006 Firefox runs this bit of code fine with no errors in the javascript console, but IE fails and doesn't want to execute it:[code]function ShowImage(URL, WIDTH, HEIGHT) { // Get URL and image size from PHP // Get width of currently open window var w = document.body.clientWidth; var h = document.body.clientHeight; // Center Window var leftPos = (w - WIDTH)/2, topPos = (h - HEIGHT) /2; // Add to the width and height to show images properly WIDTH = WIDTH + 25; HEIGHT = HEIGHT + 25; // Create a somewhat unique ID number for the window id = <?php echo rand(900, 999);?> // Open up a window and display the image. eval("page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + WIDTH + ',height=' + HEIGHT + ',left = ' + leftPos + ',top = '+ topPos + '')");}[/code]It is called via:[code]<?phpecho "<a href=\"javascript:ShowImage('photos/{$photos['filename']}', $width, $height);\"><img src=\"photos/thumb_{$photos['filename']}\" alt=\"{$photos['filename']}\" border=\"=\" /></a> ";?>[/code]All the parameters get passed, so I am not sure what is wrong. On http://www.tingram.ca the IE javascript error window says[code]Line: 1Char: 1Error: Object ExpectedCode: 0URL: http://tingram.ca[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23176-what-is-wrong-with-this-bit-o-code/ Share on other sites More sharing options...
fenway Posted October 6, 2006 Share Posted October 6, 2006 First, the code is fine, and executes on IE (at least with dummy input); the link you posted has other syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/23176-what-is-wrong-with-this-bit-o-code/#findComment-105020 Share on other sites More sharing options...
SharkBait Posted October 6, 2006 Author Share Posted October 6, 2006 There is a WYSIWYG editor I use that is javascript based. Would that effect the popup window I am trying to do with JS? Quote Link to comment https://forums.phpfreaks.com/topic/23176-what-is-wrong-with-this-bit-o-code/#findComment-105039 Share on other sites More sharing options...
fenway Posted October 6, 2006 Share Posted October 6, 2006 Not sure... but you have to fix that syntax error first. Quote Link to comment https://forums.phpfreaks.com/topic/23176-what-is-wrong-with-this-bit-o-code/#findComment-105078 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.