CSS Opacity and Flash Problems in Mac Firefox 2

CSS Opacity and Flash Problems in Mac Firefox 2

Posted by stella on Sun, 2008-07-20 23:52 in

I recently ran into an issue with the Lightbox2 module which kept me puzzled for quite some time. The problem was that when trying to view a Flash video in a lightbox on Firefox 2 on a Mac, the picture would never appear, though I could hear the sound okay. However, everything worked perfectly in Firefox 3 on the Mac, and in both Firefox 2 and 3 on Windows and Ubuntu! Lightbox2 also worked fine when displaying other content types (e.g. images) on the Mac, it was just Flash videos that were affected.

After a bit of messing around with the code, I eventually narrowed it down to a conflict between the lightbox overlay background and the flash object. If I removed the overlay, then the video would display, as soon as I put it back everything stopped working again. Initially I thought it was a problem with the z-index settings and tried tweaking that to no avail. Eventually, I figured out that removing just the overlay opacity attribute fixed the issue.

However, removing the overlay opacity or transparency wasn't something I wanted to do, certainly not for all browsers and platforms, so I wrote the following javascript function to detect Mac Firefox 2 browsers. It may be of benefit to some of you who have encountered the same problem.

function detectMacFirefox2 {
  var ua = navigator.userAgent.toLowerCase();
  if (/firefox[\/\s](\d+\.\d+)/.test(ua)) {
    var firefox_version = new Number(RegExp.$1);
    if (firefox_version < 3 && ua.indexOf('mac') != -1) {
      return true;
    }
  }
  return false;
}

Using this function I was able to detect Mac Firefox 2 browsers, and in such cases Lightbox2 now removes the opacity attribute from the overlay, thereby making it opaque. However, I went one step further and it now only removes the opacity attribute if a video is being viewed. If any other content is being displayed in the lightbox, and for all other browsers and platforms, the opacity setting is kept and everything works as expected.

I hope this article helps some of you who have encountered the same problem.

[Update: since writing this article, I found a similar one posted in Jake Olsen's blog. It's interesting to note his solution is almost identical to mine!]

How it uses?

Hi Stella,
First of all, thanks for your contribution...
I'm actually trying to use LightBox and I noticed it doesn't work in FF mac. Googled and I found your post... but... I don't know how to use your function...
Where should I include it? How and where should I call it?
Please, help me!
Thanks a lot
Gabriela

Posted by Gabriela (not verified) on Thu, 2008-09-25 16:26
Is this the Drupal Lightbox2

Is this the Drupal Lightbox2 module you're using? Or are you using Lightbox2 from huddletogether.com or some other source?

Posted by stella on Thu, 2008-09-25 16:36
Hello again I'm using this

Hello again
I'm using this one: http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm
Thanks for your answer!

Posted by Gabriela (not verified) on Thu, 2008-09-25 19:59
Doesn't support Flash

That is the original Lightbox2 script by huddletogether.com. However, it doesn't support display of Flash videos in the lightbox which is what this post is about. I think you have a different issue I'm afraid.

Posted by stella on Thu, 2008-09-25 22:47
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <br> <span>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.