0

I'm trying to apply different styles for browsers that don't support CSS3 3d transforms. But for some reason, when I preview the page in opera it applies the styles for a 3D browser, even though it doesn't (to my knowledge) support CSS3 3d transforms.

  function has3d() {
    var threedee, has3d;
        threedee = document.createElement('div');
        threedee.style['transform'] = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
        document.body.insertBefore(threedee, document.body.lastChild);
        has3d = window.getComputedStyle(threedee).getPropertyValue('transform');

    if( has3d !== undefined ){
        //Apply styles for awesome browsers that do support 3d
    }
    else {
        //Apply Styles for lame browsers that don't support 3d
    }
}

I know that the script is working, because when I switch the classes in the conditional it works in chrome, safari, and firefox. I just can't figure out why Opera seems to be saying that it supports 3d transforms. Is there something special I need to do for opera?

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
mmm
  • 2,272
  • 3
  • 25
  • 41
  • You could try using Modernizr. Anyways, here's the code that's generated from Modernizr for only testing the CSS3 transform 3d (it doesn't work or do anything, it's just the code): http://jsfiddle.net/aFfQ7/ - important part is line 199 – Ian May 15 '13 at 18:51
  • Why do you care about Opera? It's literally on the cusp of disappearing as a separate rendering engine. – Rich Bradshaw May 15 '13 at 18:54
  • I don't care about opera, but at my work for the products we're developing unfortunately some of our customers do. – mmm May 15 '13 at 19:22
  • Thanks for that Ian, I'm checking right now to see if I can make it do what I want it to. – mmm May 15 '13 at 19:41
  • Actually, Modernizr isn't really helping. – mmm May 15 '13 at 19:45
  • what is the output of `console.log(has3d)`? – methodofaction May 15 '13 at 21:40
  • output of console.log(has3d) = Unhandled Error: Undefined variable: has3d – mmm May 16 '13 at 22:02
  • are you console logging from the dev console in the fiddle? if so all vars are undefined since the fiddle is sandboxed – chiliNUT May 02 '15 at 00:54

0 Answers0