views:

529

answers:

4

Hello everyone, I have a problem with javascript code. I copied the code for the "light box" (just without the black background) off the internet. It works in Firefox, Safari and it does not work in IE for some reasons.
You can see this problem on my portfolio website on the second page at svetlana-konetskaia.com/final. Could you please suggest me anything?

A: 

IE is finicky when it comes to links with both an href and an onclick. The return false; is not enough to override the default action of the link, which is to navigate away from the page.

Add

event.returnValue = false;

to each of your links before the return false; in the onclick function.

Like this:

<div id="picture_1"><a href="images/surrealists_large.png" onClick="dv.showDV(surrealists); event.returnValue = false; return false"><img src="images/surrealists_small.png" /></a></div>
samiz
This doesn't seem right. MSIE's event.returnValue offers another way to cancel an event which takes precedence over the JScript return false in IE, but it is not the only way. It also differs slightly as to how it cancels the event. As far back as IE5 I see 'return false;' properly canceling the link's default click. Feel free to test it yourself at http://jsbin.com/uxoku
coderjoe
A: 

If you are looking to have the lightwindow effect, just without the blackout... why not use something like lightwindow, which will allow you to show nearly any media type.

http://www.stickmanlabs.com/lightwindow/

jhensley2
A: 

Hi, I fixed a few errors on my website and the lightbox still doesn't work.

I also tried to insert this line event.returnValue = false; and it didn't work as well. Thanks for your suggestions anyway.

Stack Overflow tip: next time you should really respond by commenting on the other answers, not by posting an "answer" that really isn't.
machineghost
A: 

When I try to use your lightbox I get an error related to a standardbody variable not existing. This is in an IE-specific block of code, but I wasn't clear whether you wrote the code or whether it was part of the lightbox code you copied.

Either way, you need to figure out why your code expects that variable to be there (and more importantly, why it isn't there) if you want to make your lightbox work.

machineghost