权限没有,则隐藏 function forum_list_access_filter($forumlist, $gid, $allow = 'allowread') { global $grouplist; if (empty($forumlist)) return array(); if (1 == $gid) return $forumlist; $forumlist_filter = $forumlist; $group = $grouplist[$gid]; foreach ($forumlist_filter as $fid => $forum) { if (empty($forum['accesson']) && empty($group[$allow]) || !empty($forum['accesson']) && empty($forum['accesslist'][$gid][$allow])) { unset($forumlist_filter[$fid]); } unset($forumlist_filter[$fid]['accesslist']); } return $forumlist_filter; } function forum_filter_moduid($moduids) { $moduids = trim($moduids); if (empty($moduids)) return ''; $arr = explode(',', $moduids); $r = array(); foreach ($arr as $_uid) { $_uid = intval($_uid); $_user = user_read($_uid); if (empty($_user)) continue; if ($_user['gid'] > 4) continue; $r[] = $_uid; } return implode(',', $r); } function forum_safe_info($forum) { //unset($forum['moduids']); return $forum; } function forum_filter($forumlist) { foreach ($forumlist as &$val) { unset($val['brief'], $val['announcement'], $val['seo_title'], $val['seo_keywords'], $val['create_date_fmt'], $val['icon_url'], $val['modlist']); } return $forumlist; } function forum_format_url($forum) { global $conf; if (0 == $forum['category']) { // 列表URL $url = url('list-' . $forum['fid'], '', FALSE); } elseif (1 == $forum['category']) { // 频道 $url = url('category-' . $forum['fid'], '', FALSE); } elseif (2 == $forum['category']) { // 单页 $url = url('read-' . trim($forum['brief']), '', FALSE); } if ($conf['url_rewrite_on'] > 1 && $forum['well_alias']) { if (0 == $forum['category'] || 1 == $forum['category']) { $url = url($forum['well_alias'], '', FALSE); } elseif (2 == $forum['category']) { // 单页 $url = ($forum['threads'] && $forum['brief']) ? url($forum['well_alias'] . '-' . trim($forum['brief']), '', FALSE) : url($forum['well_alias'], '', FALSE); } } return $url; } function well_forum_alias() { $forumlist = forum_list_cache(); if (empty($forumlist)) return ''; $key = 'forum-alias'; static $cache = array(); if (isset($cache[$key])) return $cache[$key]; $cache[$key] = array(); foreach ($forumlist as $val) { if ($val['well_alias']) $cache[$key][$val['fid']] = $val['well_alias']; } return array_flip($cache[$key]); } function well_forum_alias_cache() { global $conf; $key = 'forum-alias-cache'; static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,跨进程需要再加一层缓存:redis/memcached/xcache/apc if (isset($cache[$key])) return $cache[$key]; if ('mysql' == $conf['cache']['type']) { $arr = well_forum_alias(); } else { $arr = cache_get($key); if (NULL === $arr) { $arr = well_forum_alias(); !empty($arr) AND cache_set($key, $arr); } } $cache[$key] = empty($arr) ? '' : $arr; return $cache[$key]; } ?>javascript - Detect Firefox < 3.6 - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect Firefox < 3.6 - Stack Overflow

programmeradmin9浏览0评论

I tried to find any good solution to detect firefox versions < 3.6 in order to deliver a notice to them that my website works much better in newer browsers (at least 3.6). I stubled across .browser/ - but found no example how to detect all Versions lower than 3.6. Any advice?

Thank you!

I tried to find any good solution to detect firefox versions < 3.6 in order to deliver a notice to them that my website works much better in newer browsers (at least 3.6). I stubled across http://api.jquery./jQuery.browser/ - but found no example how to detect all Versions lower than 3.6. Any advice?

Thank you!

Share Improve this question edited Feb 1, 2012 at 12:49 skaffman 404k96 gold badges824 silver badges775 bronze badges asked Feb 1, 2012 at 12:48 cukabekacukabeka 5302 gold badges9 silver badges22 bronze badges 2
  • 1 Which feature do you need to detect? Do that instead. – BalusC Commented Feb 1, 2012 at 12:50
  • Maybe it's performance related. – James M Commented Feb 1, 2012 at 12:52
Add a ment  | 

4 Answers 4

Reset to default 4
/* ===== Firefox ===== */

// Select Firefox
if (jQuery.browser.mozilla) {
    // do sth.
}

// Select Firefox 1.5.x to 2.x
if (jQuery.browser.mozilla && jQuery.browser.version.substr(0, 3) == '1.8') {
    // do sth.
}

// Select Firefox under 3.x
if (jQuery.browser.mozilla && jQuery.browser.version < '1.9') {
    // do sth.
}

// Select Firefox 3.0.x and above
if (jQuery.browser.mozilla && jQuery.browser.version.substr(0, 3) == '1.9') {
    // do sth.
}

// Select just Firefox 2.0.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.8.1') {
    // do sth.
}

// Select just Firefox 3.0.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9') {
    // do sth.
}

// Select just Firefox 3.5.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9.1') {
    // do sth.
}

// Select just Firefox 3.6.x
if (jQuery.browser.mozilla && jQuery.browser.version == '1.9.2') {
    // do sth.
}

/* ===== Internet Explorer ===== */

// Select Internet Explorer
if (jQuery.browser.msie) {
    // do sth.
}

// Select Internet Explorer above 6
if (jQuery.browser.msie && jQuery.browser.version > 6) {
    // do sth.
}

// Select Internet Explorer 7 and below
if (jQuery.browser.msie && jQuery.browser.version <= 7) {
    // do sth.
}

// Select just Internet Explorer 6
if (jQuery.browser.msie && jQuery.browser.version == '6.0') {
    // do sth.
}

// Select just Internet Explorer 7
if (jQuery.browser.msie && jQuery.browser.version == '7.0') {
    // do sth.
}

// Select just Internet Explorer 8
if (jQuery.browser.msie && jQuery.browser.version == '8.0') {
    // do sth.
}

// Select just Internet Explorer 9
if (jQuery.browser.msie && jQuery.browser.version == '9.0') {
    // do sth.
}

/* ===== Safari / Chrome ===== */

// Select Safari / Chrome
if (jQuery.browser.safari) {
    // do sth.
}

// Select Safari 3
if (jQuery.browser.safari && (navigator.appVersion.indexOf('3.') != -1)) {
    // do sth.
}

// Select Safari 4
if (jQuery.browser.safari && (navigator.appVersion.indexOf('4.') != -1)) {
    // do sth.
}

// Select Chrome 1
if (jQuery.browser.safari && (navigator.appVersion.indexOf('1.') != -1)) {
    // do sth.
}

// Select Chrome 3
if (jQuery.browser.safari && (navigator.appVersion.indexOf('3.') != -1)) {
    // do sth.
}

/* ===== Opera ===== */

// Select Opera
if (jQuery.browser.opera) {
    // do sth.
}

// Select Opera 9.5 and above
if (jQuery.browser.opera && jQuery.browser.version >= '9.5') {
    // do sth.
}

// Select just Opera 9.5
if (jQuery.browser.opera && jQuery.browser.version == '9.5') {
    // do sth.
}

// Select just Opera 10
// Note: Opera 10's user agent looks like Opera/9.80 [...] Version/10.00
if (jQuery.browser.opera && jQuery.browser.version == '9.8') {
    // do sth.
}

Try this

var itsOldFF = false;
var itsFF = false;
$.each($.browser, function (i, val) {
   if (i == "mozilla" && itsFF == false){
      itsFF = true;
      return;
   }
   if(itsFF && parseFloat(val) < 3.6) itsOldFF = true;
}); 
return itsOldFF;

EDIT

Demo on jsFiddle

In general you are better off detecting features not versions. Detect whichever features you need and not the version number

var ua = $.browser;
if (ua.mozilla && parseFloat(ua.version.slice(0,3)) < 3.6) {
    alert( "Do stuff for firefox 3.6 or less" );
}
发布评论

评论列表(0)

  1. 暂无评论