• JavaScript判断浏览器UA 、 添加收藏 、设置首页 、调用本地邮箱发送邮件


    if (typeof Browser == "undefined")
    	Browser = {};
    Browser = {
    	Versions : function() {
    		var u = navigator.userAgent, app = navigator.appVersion;
    		return {// 移动终端浏览器版本信息
    			trident : u.indexOf('Trident') > -1, // IE内核
    			presto : u.indexOf('Presto') > -1, // opera内核
    			webKit : u.indexOf('AppleWebKit') > -1, // 苹果、谷歌内核
    			gecko : u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, // 火狐内核
    			mobile : !!u.match(/AppleWebKit.*Mobile.*/)
    					|| !!u.match(/AppleWebKit/), // 是否为移动终端
    			ios : !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/), // ios终端
    			android : u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, // android终端或者uc浏览器
    			iPhone : u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, // 是否为iPhone或者QQHD浏览器
    			iPad : u.indexOf('iPad') > -1, // 是否iPad
    			webApp : u.indexOf('Safari') == -1
    		// 是否web应该程序,没有头部与底部
    		};
    	}(),
    	Language : (navigator.browserLanguage || navigator.language).toLowerCase(),
    	isWap : navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)
    }
    
    /**
     **   加入收藏 <a onclick="AddFavorite(window.location,document.title)">加入收藏</a>
     ***/
    function AddFavorite(url, title) {
        if (navigator.userAgent.indexOf('Trident') > -1) { // ie
            window.external.AddFavorite(url, title);
        } else {
            alert("请您使用Ctrl+D进行添加收藏夹;");
            return;
        }
    
        if (window.sidebar) { // firefox
            window.sidebar.addPanel(title, url, "");
        } else if (window.opera && window.print) { // opera
            var elem = document.createElement('a');
            elem.setAttribute('href', url);
            elem.setAttribute('title', title);
            elem.setAttribute('rel', 'sidebar');
            elem.click(); // this.title=document.title;
        }
    }
    
    /***
     *  设为首页 <a onclick="SetHome(this,window.location)">设为首页</a>
     */
    function SetHome(obj, vrl) {
        try {
            obj.style.behavior = 'url(#default#homepage)';
            obj.setHomePage(vrl);
        } catch (e) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                } catch (e) {
                    alert("此操作被浏览器拒绝!
    请在浏览器地址栏输入“about:config”并回车
    然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
                }
                var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                prefs.setCharPref('browser.startup.homepage', vrl);
            }
        }
    }
    
    /***
     *  发送邮件
     <a href="mailto:xinghaifang623@163.com?subject=欢迎您来信&body=写下您的建议"> 
     */
    function SendMail(mail, subject, body) {
    
    }
    

      

    缘来天注定,缘去人自夺。种如是因,收如是果,一切唯心造。笑言面对,不去埋怨。悠然、随心、随性、随缘。
  • 相关阅读:
    Java之JDBC操作
    Ubuntu17安装MySql5.7
    应用解决告诉你什么时候该用ajax
    jquery插件大全
    面试题:谈谈如何优化MYSQL数据库查询
    1亿条数据在PHP中实现Mysql数据库分表100张
    DEDECMS教程:首页实现分页的两种方法
    Dedecms当前位置{dede:field name='position'/}修改,去掉>方法
    mysql的MyISAM 和 InnoDB 的区别?优化MYSQL数据库的方法?
    COOKIE和SESSION关系和区别等
  • 原文地址:https://www.cnblogs.com/gaojianqi/p/3611726.html
Copyright © 2020-2023  润新知