0

I'm trying to make an IE fallback for Dave Dessandro's card flip script https://desandro.github.io/3dtransforms/docs/card-flip.html and so far I have it working for every IE version except for 8. It's throwing the code error:

IE8 object does not support this property or method 

Where the error seems to appear is in this line of code:

document.getElementById("info").addEventListener( "click", function(){

The complete function is here:

// Assign click action to flip card question
document.getElementById("info").addEventListener( "click", function(){
    card.toggleClassName("flipped");
    }, false);
};

I cannot see what the issue is? Is there anything that I am missing? For the complete code, please see https://github.com/SLQ-web/Fauna/blob/Koala/js/card-flip.js

Is this just something that IE8 refuses to do? It's a toggle that flips a card in 3D for browsers that support preserve3d and csstransform. For other older browsers, it just shows and hides the image. Have used Modernizr to set targeted classes.

Ryan Coolwebs
  • 1,611
  • 5
  • 22
  • 44

1 Answers1

1

IE8 does not support addEventListener. You can use event handlers instead:

document.getElementById("info").onclick = function() {
  card.toggleClassName("flipped");
};

Or, if you really need event listeners, IE8 has a non-standard attachEvent:

document.getElementById("info").attachEvent('onclick', function() {
  card.toggleClassName("flipped");
});
Oriol
  • 274,082
  • 63
  • 437
  • 513