Wednesday, 22 July 2009

Error: Lightbox is 'undefined' when using Lightbox from Flash on IIS

Today I came across an issue with Lightbox (the javascript image gallery) and after ages of trying to find out what it was everyone seemed to be saying the problem was in the JavaScript and how it was called.

The thing that made me think otherwise was the exact same website was working perfectly on another server which was Linux. After looking around the code I noticed the lightbox file was called lightbox++.js

Every time you clicked on an image in the gallery I got the Error: Lightbox is 'undefined' and in FireFox - 'Lightbox is not defined.

On a hunch i tried entering the path in the lightbox.js file into the address bar and IIS said the file didn't exist! I then had a lightbulb moment.

IIS doesn’t seem to like the + character in the lightbox++.js file name and wouldn’t serve up the file so I renamed to lightbox.js and updated the reference in the calling page and bingo! It works fine.

So if you get the Error: Lightbox is 'undefined' message and are using a Windows server and IIS then don't use + in the file name!

5 comments:

lokeshkumar said...

Nice.Good one
Thank you

Lokeshkumar said...

Thank you.
It worked for me also

Anonymous said...

I just spent 2 hours looking for a fix. I couldn't figure out why this worked on other IIS servers and not this one! Turns out that the website I'm working on is ASP NET 4.0 - the other sites are 2.0 and 1.1! Renaming the file worked like a charm THANK YOU!!!

Anonymous said...

You made my day! Thank you so much. I doubted my capabilities... but my web-crawling-skills directed me to your page!

Thx!

Anonymous said...

Thanx so much for the tip. You saved me from wasting hours of debug.... gotta have ISS servers haha, thanx man!