Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top