Search code examples
javascriptdebugginginternet-explorer-7lightwindow

LightWindow & IE7, "Line 444 - object does not support this property or method"


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.


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.