Search code examples
javascriptflashoperaopera-turbo

Is Opera Turbo on?


I've got a page which uses Flash with animations (These are not crucial but additional).

Everything works fine, if I'm not using Opera with activated Turbo. Then the Flash Movie is shown as a big ugly arrow in a circle the size of the flash movie which is intended to act as a play button for the flash.

I'm using SWFobject, so I easily could turn of the animation if I knew if Opera's turbo mechanism is used, but how do I do this in JavaScript (or maybe CSS if this goes)


How to reproduce?
Surf this page with Opera (or any other page which uses flash)
http://www.adobe.com/software/flash/about/
Without Opera Turbo you see a flash animation and flash version information With Opera Turbo you see two white arrows in gray circles


edit 1 I'm quite sure now, that there is not a pure JS solution and not a PHP solution. The best guess is a combined AS/JS solution.


Solution

  • You can try to check if the flash object is loaded with some javascript. This code works on my computer with Opera 11:

    <html>
    <head>
      <script language=JavaScript>
        function isFlashBlocked(){
          var blocked;
          try {
            // Can test this on any flash object on the page
            window.document.myFlash.SetVariable("dummy", "dummy");
            // Flash not blocked
            blocked = false;
          }
          catch(err) {
            // Flash blocked
            blocked = true;
          }
    
          return blocked;
        }
    
        function removeBlockedFlash() {
          if (isFlashBlocked()) {
            // Hide all flash objects
            window.document.myFlash.setAttribute("style", "display: none");
            // ...
    
            // Display replacement content
            window.document.myImage.setAttribute("style", "display: inline");
            // ...
          }
        }
      </script>
    </head>
    <body onload="removeBlockedFlash()">
      <object type="application/x-shockwave-flash" data="HelloWorld.swf" 
              width="100" height="100" id="myFlash">
      </object>
      <img src="image.jpg" style="display: none" id="myImage" />
    </body>
    </html>
    

    If you detect that flash is blocked, you hide every flash object and display what you want.

    Edit: This code doesn't work with Firefox, you probably need to detect the browser before using this function.