Destoon框架中的一些JS

Destoon框架中的JS函数

  • 判断移动端类型
var UA = navigator.userAgent.toLowerCase();
  • 判断是不是IE浏览器
var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;
  • 判断当前是不是webkit内核
var isGecko = UA.indexOf('webkit') != -1;
  • 判断当前的用户协议,主机名,端口
var DMURL = document.location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + '/';
  • 跳转函数
function Go(u) {
    window.location = u;
}
  • 带提示的跳转函数
function confirmURI(m, f) {
    if(confirm(m)) window.location = f;
}
  • 桌面通知属性
function Dnotification(id, url, icon, title, content) {
    if(window.webkitNotifications) {
        if(webkitNotifications.checkPermission() == 1) {
            window.onclick = function() {
                window.webkitNotifications.requestPermission(function() {
                    if(webkitNotifications.checkPermission() == 0) {
                        var N = window.webkitNotifications.createNotification(icon, title, content);
                        N.replaceId = id;
                        N.onclick = function() {
                            window.focus();
                            window.top.location = url;
                            N.cancel();
                        };
                        N.show();
                    }
                });
            };
        } else if(webkitNotifications.checkPermission() == 0) {
            var N = window.webkitNotifications.createNotification(icon, title, content);
            N.replaceId = id;
            N.onclick = function() {
                window.focus();
                window.top.location = url;
                N.cancel();
            };
            N.show();
        }
    }
}
  • 缓存机制
function set_cookie(n, v, d) {
    var e = '';
    var f = d ? d : 365;
    e = new Date((new Date()).getTime() + f * 86400000);
    e = "; expires=" + e.toGMTString();
    document.cookie = CKPrex + n + "=" + v + ((CKPath == "") ? "" : ("; path=" + CKPath)) + ((CKDomain == "") ? "" : ("; domain=" + CKDomain)) + e;
}

function get_cookie(n) {
    var v = '';
    var s = CKPrex + n + "=";
    if(document.cookie.length > 0) {
        o = document.cookie.indexOf(s);
        if(o != -1) {
            o += s.length;
            end = document.cookie.indexOf(";", o);
            if(end == -1) end = document.cookie.length;
            v = unescape(document.cookie.substring(o, end));
        }
    }
    return v;
}

function del_cookie(n) {
    var e = new Date((new Date()).getTime() - 1);
    e = "; expires=" + e.toGMTString();
    document.cookie = CKPrex + n + "=" + escape("") + ";path=/" + e;
}

function set_local(n, v) {
    window.localStorage ? localStorage.setItem(CKPrex + n, v) : set_cookie(n, v);
}

function get_local(n) {
    return window.localStorage ? localStorage.getItem(CKPrex + n) : get_cookie(n);
}

function del_local(n) {
    window.localStorage ? localStorage.removeItem(CKPrex + n) : del_cookie(n);
}
  • 返回顶部
$(document).ready(function() {
    $(window).bind("scroll.back2top", function() {
        var st = $(document).scrollTop(),
            winh = $(window).height();
        (st > 0) ? $('.back2top').show(): $('.back2top').hide();
        if(!window.XMLHttpRequest) {
            $('.back2top').css("top", st + winh - 166);
        } //IE6
    });
    $('.back2top').click(function() {
        $("html, body").animate({
            scrollTop: 0
        }, 200);
    });
});

下面是框架里边的一个跑马灯效果



    
        
        
        

    

    
        
  • 产品总数:0
  • 求购总数:0
  • 企业总数:1
  • 在线会员:0
效果展示.png

你可能感兴趣的:(Destoon框架中的一些JS)