tags:

views:

281

answers:

1

I have a webapp embedding some flash content in an iframe. The flash part is requesting access to the webcam. On firefox/mac os, user's can't click the allow button. This only happens when the page embedding the swf file is loaded in the iframe, it works fine when laded separately. Has anyone else faced a similar problem? Do you know any workarounds?

EDIT: For future reference: we were positioning some stuff via JS and we had positions using "half pixels" (e.g. 20.5px). Once we fixed that everything worked fine.

Thanks, Alex

+2  A: 

I found that this bug will also exist in situations when you use margin auto in CSS.

For example, in a fixed width & center aligned layout its typical to use "margin: 0px auto;" to keep a content well centered. This seems to produce possible (likely) decimal left/right margins for the content well. That isn't really a problem for Firefox.. it handles decimal pixel offsets just fine.

But Flash widgets totally seem to freak out when their object container are positioned with decimal pixel values. At minimum, you cannot interact with the "Allow" button. To me, this seems to be the root cause of this bug you will see widely reported by many (as it pertains to FF atleast).

As for why it only occurs in FF, I'm not entirely sure. On my OSX machine, Safari and Chrome don't exhibit this behavior with flash objects. Perhaps all DOM elements in Webkit are rendered with rounded pixel offset values automatically?

For Firefox, I implemented this workaround (useful for center aligned designs):

$(document).ready( function() {
  repositionContentContainer();
});

function repositionContentContainer() {
  // this routine is a complete hack to work around the flash "Allow" button bug
  if ( $("#content").length > 0 ) {

    //Adjust the #content left-margin, since by default it likely isn't an int
    setLeftMargin();
    //If the User resizes the window, adjust the #content left-margin
    $(window).bind("resize", function() { setLeftMargin(); });
  }
}

function setLeftMargin() {
  var newWindowWidth = $(window).width();
  var mainWellWidth = $("#content").width();
  // create an integer based left_offset number
  var left_offset = parseInt((newWindowWidth - mainWellWidth)/2.0);
  if (left_offset < 0) { left_offset = 0; }
  $("#content").css("margin-left", left_offset);
}
sghael