views:

2214

answers:

5

I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of lightwindow.js, claiming that the "object does not support this property or method". Despite finding various postings on various forums, no Google result I could find had a solution, so I am posting this here in the hopes that it will help someone / myself later.

Many suggested a specific order of the script files but I was already using this order (prototype, scriptaculous, lightwindow).

These are the steps I took that seemed to finally work, I write them here only as a record as I do not know nor have time to test which ones specifically "fixed" the issue:

  1. Moved the call to lightwindow.js to the bottom of the page.
  2. Changed line 444 to: if (this._getGalleryInfo(link.rel)) {
  3. Changed line 1157 to: if (this._getGalleryInfo(this.element.rel)) {
  4. Finally, I enclosed (and this is dirty, my apologies) lines 1417 to 1474 with a try/catch block, swallowing the exception.

EDIT: I realised that this broke Firefox. Adding the following as line 445 now makes it work - try { gallery = this._getGalleryInfo(link.rel); } catch (e) { }

It's not a very nice fix, but my page (which contains a lightwindow link with no "rel" tag, several lightwindow links which do have "rel" tags, and one "inline" link) works just fine in IE7 now. Please comment if you have anything to add about this issue or problems with / improvements to my given solution.

+1  A: 

instead of the try..catch maybe you could try using

if( this && this._getGalleryInfo )
{
    //use the function

}

you could also check in the same way this.element.rel ( if(this && this.element && this.element.rel) ... ) before using it.

it looks like there's a case that the _getGalleryInfo or this.element.rel has not yet been initialized so it wouldn't exist yet. check if it exists then if i does use it.

of course i could be completely wrong, the only way to know is by testing it out.

John Boker
A: 

Hi,

I have an small question about light window. You posted an fix for it. Is this fix for the 2.0 version? And does this fix the issue with opening pictures in ie7? It seems to open sometimes an small box when you click a picture and if you click again it works fine. Very strange.

I hope it does, cause this is really nagging me hehe

greetz

A: 

I had the same problem with Lightwindow 2.0, IE6, IE7, IE8 (beta); I resolved in the following way for IE6, IE7, IE8 (beta).

Instead of:
 if(gallery = this._getGalleryInfo(link.rel))
I put on lines 443 and 1157:
 gallery = this._getGalleryInfo(link.rel)
 if(gallery)

Hope this will help!

A: 

I fixed this by changing line 444 to:

var gallery = this._getGalleryInfo(link.rel)

Then changing the subsequent comparison statement to:

if(gallery.length > 0)
{
 // Rest of code here...

...which seems to have sorted it in IE6+ and kept it working in Firefox etc.

I didn't change line 1157 at all, but I haven't read the code to see what i actually does so I can't comment on its relevance?

I suspect the ? used in the example rel attribute (Evoution?[man]) may be causing the problem with IE but without spending some time testing a few things, I can't be sure?

HTH.

A: 

i tried the fix(es) and it still doesn't work for me. i get a "line 495 no method" error ... clicking on the imagelink in the ie7 doesn't show any effect. in firefox and safari works fine...

anyone got an idea??

regards!