内容的栏目 * @param int $category 0列表 1频道 2单页 3外链 * @return array */ function category_list($forumlist, $model = 0, $display = 0, $category = 0) { if (empty($forumlist)) return NULL; static $cache = array(); $key = $model . '-' . $display . '-' . $category; if (isset($cache[$key])) return $cache[$key]; if ($display) { foreach ($forumlist as $k => $val) { if (1 == $val['display'] && 1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } else { foreach ($forumlist as $k => $val) { if (1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } return empty($cache[$key]) ? NULL : $cache[$key]; } /** * @param $forumlist 所有版块列表 不分模型 * @param int $display 0全部CMS栏目 1在首页和频道显示内容的栏目 * @param int $category 0列表 1频道 2单页 3外链 * @return array */ function category_list_show($forumlist, $display = 0, $category = 0) { if (empty($forumlist)) return NULL; static $cache = array(); $key = $display . '-' . $category; if (isset($cache[$key])) return $cache[$key]; if ($display) { foreach ($forumlist as $k => $val) { if (1 == $val['display'] && 1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } else { foreach ($forumlist as $k => $val) { if (1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } return empty($cache[$key]) ? NULL : $cache[$key]; } /** * @param $forumlist 所有版块列表 * @return mixed BBS栏目数据(仅列表) 尚未开放bbs频道功能 */ function forum_list($forumlist) { if (empty($forumlist)) return array(); static $cache = array(); if (isset($cache['bbs_forum_list'])) return $cache['bbs_forum_list']; $cache['bbs_forum_list'] = array(); foreach ($forumlist as $_fid => $_forum) { if ($_forum['type']) continue; $cache['bbs_forum_list'][$_fid] = $_forum; } return $cache['bbs_forum_list']; } // 导航显示的版块 function nav_list($forumlist) { if (empty($forumlist)) return NULL; static $cache = array(); if (isset($cache['nav_list'])) return $cache['nav_list']; foreach ($forumlist as $fid => $forum) { if (0 == $forum['nav_display']) { unset($forumlist[$fid]); } } return $cache['nav_list'] = $forumlist; } ?>javascript - Is Opera Turbo on? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is Opera Turbo on? - Stack Overflow

programmeradmin0浏览0评论

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)
/
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 bined AS/JS solution.

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./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 bined AS/JS solution.

Share Improve this question edited Apr 10, 2013 at 13:07 yunzen asked Jan 11, 2012 at 9:42 yunzenyunzen 33.4k13 gold badges78 silver badges113 bronze badges 4
  • are you still able to circumvent plugin-on-demand in Opera ? – c69 Commented Jan 11, 2012 at 9:49
  • @c69 I don't know anything about that. And I don't think this is the problem. I just switch on Turbo and there you go. Flash is installed and if you klick on the play button, flash starts to play. – yunzen Commented Jan 11, 2012 at 10:02
  • Sorry for of topic, but what is required to add bountys to a question? I've read the faq but cant seem to find it. – Johan Commented Jan 19, 2012 at 22:15
  • @Johan you need to wait 2 days after the question was asked. Then you can add bounty – yunzen Commented Jan 20, 2012 at 8:05
Add a ment  | 

3 Answers 3

Reset to default 5

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 pressions) and forward the processed content to the final client (user's puter).

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

~$ nslookup opera10beta-turbo.opera-mini
>Server:        189.40.226.80
>Address:   189.40.226.80#53
>Non-authoritative answer:
>opera10beta-turbo.opera-mini   canonical name = global-turbo-1.opera-mini.
>Name:  global-turbo-1.opera-mini
>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.

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.

You can try to check if the flash object is loaded with some javascript. This code works on my puter 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.

I believe that the answer to the speed issue is that the Flash content is not downloaded initially. You have to manually click on the icon to download it. Same for animated GIFs. This is part of the strategy to boost the speed. (cf., this Opera Desktop Team post.)

Which is why you want to know how to check for Opera Turbo, and not just Opera. From my local tests, I cannot tell the difference using PHP's _SERVER["HTTP_USER_AGENT"] variable. I think this is similar to what Opera lists as the user agent string, as shown here and here.

It seems that, rather notifying the website of the browser condition, Opera silently manages the request results differently.

发布评论

评论列表(0)

  1. 暂无评论