Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 746
yunzen Avatar asked Jan 17 '23 20:01

yunzen


2 Answers

Client side detection: There is no way to access that through javascript. Client side detection for opera turbo is not possible currently, maybe it will be supported in the future but who knows?

Server side detection: When opera turbo is enabled all requests from client are done to opera servers, the opera servers are going to access your application (do compressions) and forward the processed content to the final client (user's computer).

With that in mind, let's do some network sniffing and see where are your connection going:

~$ nslookup opera10beta-turbo.opera-mini.net
>Server:        189.40.226.80
>Address:   189.40.226.80#53
>Non-authoritative answer:
>opera10beta-turbo.opera-mini.net   canonical name = global-turbo-1.opera-mini.net.
>Name:  global-turbo-1.opera-mini.net
>Address: 141.0.11.252

~$ nslookup 64.255.180.252
>Server:        192.168.1.254
>Address:   192.168.1.254#53
>Non-authoritative answer:
>252.180.255.64.in-addr.arpa    canonical name = 252.0-24.180.255.64.in-addr.arpa.
>252.0-24.180.255.64.in-addr.arpa   name = global-turbo-1-lvs-usa.opera-mini.net.

As you can see the name and canonical name from opera servers can be used to detect if you application is being accessed through opera servers intermediation. I think server side coding could handle that (not sure what language are you using on your server).

It's good to remember that Opera Turbo will not intermediate your requests if you're accessing something in your local server.

Hope it helps.

like image 77
marcio Avatar answered Jan 24 '23 23:01

marcio


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.

like image 37
Lesque Avatar answered Jan 25 '23 00:01

Lesque