Jump to content

Image pop-up not working correctly


sdways01
 Share

Recommended Posts

I am having a problem with a gallery type page on a website I am working on. I have various thumbnail images on the page. Each image when clicked is suppose to bring up a new window sized for that image. If the new window is clicked, it should then close. The problem I am having is related to where the image to be displayed is stored. I am using a site where I store photos so I don't have to have the images stored in the same place the website is stored. If I have the photo I want to display stored in the same place as my website, everything works just fine. If I try to use the photo from my other photo storage page, the new image window will come up, the photo will be in the window, but the photo won't be positioned quite right and the window can't be closed by clicking on it. This only happens when using IE, if I use the page on Firefox, it works fine both ways.I am looking for help/knowledge of why this is happening and if I can work around it without needing to store all my images where the website is stored.This is my function that is suppose to bring up a certain sized new window to display an image and if clicked, close the window back down.

function showImage(img,w,h) {   var newWind = window.open(img,'photo','width='+w+',height='+h+',menubar=no,location=no,resizable=no,scrollbars=no,status=no');   newWind.document.write('<html><head><title>Click to Close</title></head><body style="margin:0; padding:0" onclick="self.close()"><img src="'+img+'" width="'+w+'" height="'+h+'" alt="photo" title="Click on photo to close this window" /></body></html>');   newWind.focus();}

This is the code that has a thumbnail image that is clicked to call the function and get a larger image in a new window

<a href="java script:;" onclick="showImage('http://sdways01.smugmug.com/Mt-Monadnock/Points-of-Interest/Monadnock7620/862609843_Btpdr-800x640.jpg',800,640)"><img src="http://sdways01.smugmug.com/Mt-Monadnock/Points-of-Interest/Monadnock7620/862609843_Btpdr-100x80.jpg" alt="Ainsworth’s Seat" /></a>

Edited by sdways01
Link to comment
Share on other sites

Try to add an onclick handler to the image also. Does the popup window cause any Javascript errors when you click in IE? You may want to give your popup page a doctype also.
I will try those and see if they work.There is no noticeable error that happens when you click in IE. No message comes up is what I mean. But the status bar on the bottom of the main window shows "Error on page"
Link to comment
Share on other sites

I will try those and see if they work.There is no noticeable error that happens when you click in IE. No message comes up is what I mean. But the status bar on the bottom of the main window shows "Error on page"
you might want to check that out...
Link to comment
Share on other sites

you might want to check that out...
I've been trying a few different ways to try and track that down without any luck. Putting the code in the fuction directly into a page works without error and changing the image location works without error. The code validates as well on the entire page and I have looked into the features/syntax of each tag being used. Is there an add-on to IE to get the message of the error similar to the "error console" in Firefox?
Link to comment
Share on other sites

have you tried double clicking on it? or just google "show error console IEx" without whatever version of IE you have. HTML/CSS validation won't check for javascript, hence why there's an error console.If you have IE8, that comes with a developers workbench/toolbar included, you just need to open it using F12.

Edited by thescientist
Link to comment
Share on other sites

have you tried double clicking on it? or just google "show error console IEx" without whatever version of IE you have. HTML/CSS validation won't check for javascript, hence why there's an error console.If you have IE8, that comes with a developers workbench/toolbar included, you just need to open it using F12.
Thank you, I didn't know I had that feature. I will use that to keep debugging.
Link to comment
Share on other sites

Using the developers toolbar, I was able to find out more about the problem. The error it was giving me was "Access is denied." After doing some more debugging and research, I found out it is because IE doesn't allow Cross-Domain Communication. Meaning I can't do all the window manipulation I want with the image in the new window being on another domain. Hence why it all works when I store the image on my domain. Guess I need to change my plans now. Thanks to those that helped.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...