Jump to content

Recommended Posts

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]
<?php
echo "<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: 1
Char: 1
Error: Object Expected
Code: 0
URL: http://tingram.ca
[/code]

Link to comment
https://forums.phpfreaks.com/topic/23176-what-is-wrong-with-this-bit-o-code/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.