• jQuery1.9不支持browser和live,iealert修改


    $("body").iealert({

    support: "ie8"

    });

    方法一:

    (function(jQuery){ 
    
    if(jQuery.browser) return; 
    
    jQuery.browser = {}; 
    jQuery.browser.mozilla = false; 
    jQuery.browser.webkit = false; 
    jQuery.browser.opera = false; 
    jQuery.browser.msie = false; 
    
    var nAgt = navigator.userAgent; 
    jQuery.browser.name = navigator.appName; 
    jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion); 
    jQuery.browser.majorVersion = parseInt(navigator.appVersion,10); 
    var nameOffset,verOffset,ix; 
    
    // In Opera, the true version is after "Opera" or after "Version" 
    if ((verOffset=nAgt.indexOf("Opera"))!=-1) { 
    jQuery.browser.opera = true; 
    jQuery.browser.name = "Opera"; 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+6); 
    if ((verOffset=nAgt.indexOf("Version"))!=-1) 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+8); 
    } 
    // In MSIE, the true version is after "MSIE" in userAgent 
    else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { 
    jQuery.browser.msie = true; 
    jQuery.browser.name = "Microsoft Internet Explorer"; 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+5); 
    } 
    // In Chrome, the true version is after "Chrome" 
    else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) { 
    jQuery.browser.webkit = true; 
    jQuery.browser.name = "Chrome"; 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+7); 
    } 
    // In Safari, the true version is after "Safari" or after "Version" 
    else if ((verOffset=nAgt.indexOf("Safari"))!=-1) { 
    jQuery.browser.webkit = true; 
    jQuery.browser.name = "Safari"; 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+7); 
    if ((verOffset=nAgt.indexOf("Version"))!=-1) 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+8); 
    } 
    // In Firefox, the true version is after "Firefox" 
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) { 
    jQuery.browser.mozilla = true; 
    jQuery.browser.name = "Firefox"; 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+8); 
    } 
    // In most other browsers, "name/version" is at the end of userAgent 
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < 
    (verOffset=nAgt.lastIndexOf('/')) ) 
    { 
    jQuery.browser.name = nAgt.substring(nameOffset,verOffset); 
    jQuery.browser.fullVersion = nAgt.substring(verOffset+1); 
    if (jQuery.browser.name.toLowerCase()==jQuery.browser.name.toUpperCase()) { 
    jQuery.browser.name = navigator.appName; 
    } 
    } 
    // trim the fullVersion string at semicolon/space if present 
    if ((ix=jQuery.browser.fullVersion.indexOf(";"))!=-1) 
    jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix); 
    if ((ix=jQuery.browser.fullVersion.indexOf(" "))!=-1) 
    jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix); 
    
    jQuery.browser.majorVersion = parseInt(''+jQuery.browser.fullVersion,10); 
    if (isNaN(jQuery.browser.majorVersion)) { 
    jQuery.browser.fullVersion = ''+parseFloat(navigator.appVersion); 
    jQuery.browser.majorVersion = parseInt(navigator.appVersion,10); 
    } 
    jQuery.browser.version = jQuery.browser.majorVersion; 
    })(jQuery);
    
    (function($){
    $("#goon").on("click", function(){
            $("#ie-alert-overlay").hide();    
            $("#ie-alert-panel").hide();                          
    });
    function initialize($obj, support, title, text){
    
            var panel = "<span>"+ title +"</span>"
                      + "<p> "+ text +"</p>"
                      + "<div class='browser'>"
                      + "<ul>"
                      + "<li><a class='chrome' href='http://www.google.cn/intl/zh-CN/chrome/browser/desktop/index.html' target='_blank'></a></li>"
                      + "<li><a class='firefox' href='http://www.mozilla.org/en-US/firefox/new/' target='_blank'></a></li>"
                      + "<li><a class='ie9' href='http://windows.microsoft.com/en-US/internet-explorer/downloads/ie/' target='_blank'></a></li>"
                      + "<li><a class='safari' href='http://www.apple.com/safari/download/' target='_blank'></a></li>"
                      + "<li><a class='opera' href='http://www.opera.com/download/' target='_blank'></a></li>"
                      + "<ul>"
                      + "</div>"; 
    
            var overlay = $("<div id='ie-alert-overlay'></div>");
            var iepanel = $("<div id='ie-alert-panel'>"+ panel +"</div>");
    
            var docHeight = $(document).height();
    
            overlay.css("height", docHeight + "px");
    
    
    
                     
            
            if (support === "ie8") {             // shows the alert msg in IE8, IE7, IE6
            
                if ($.browser.msie  && parseInt($.browser.version, 10) < 9) {
                    
                    $obj.prepend(iepanel);
                    $obj.prepend(overlay);
                    
                }
    
                if ($.browser.msie  && parseInt($.browser.version, 10) === 6) {
    
                    
                    $("#ie-alert-panel").css("background-position","-626px -116px");
                    $obj.css("margin","0");
      
                }
                
                
            } else if (support === "ie7") {     // shows the alert msg in IE7, IE6
                
                if ($.browser.msie  && parseInt($.browser.version, 10) < 8) {
                    
                    $obj.prepend(iepanel);
                    $obj.prepend(overlay);
                }
                
                if ($.browser.msie  && parseInt($.browser.version, 10) === 6) {
                    
                    $("#ie-alert-panel").css("background-position","-626px -116px");
                    $obj.css("margin","0");
      
                }
                
            } else if (support === "ie6") {     // shows the alert msg only in IE6
                
                if ($.browser.msie  && parseInt($.browser.version, 10) < 7) {
                    
                    $obj.prepend(iepanel);
                    $obj.prepend(overlay);
                    
                      $("#ie-alert-panel").css("background-position","-626px -116px");
                    $obj.css("margin","0");
                    
                }
            }
    
    }; //end initialize function
    
    
        $.fn.iealert = function(options){
            var defaults = { 
                support: "ie7",  // ie8 (ie6,ie7,ie8), ie7 (ie6,ie7), ie6 (ie6)
                title: "u4F60u77E5u9053u4F60u7684Internet Exploreru662Fu8FC7u65F6u4E86u5417?", // title text
                text: "u4E3Au4E86u5F97u5230u6211u4EECu7F51u7AD9u6700u597Du7684u4F53u9A8Cu6548u679C,u6211u4EECu5EFAu8BAEu60A8u5347u7EA7u5230u6700u65B0u7248u672Cu7684Internet Exploreru6216u9009u62E9u53E6u4E00u4E2Awebu6D4Fu89C8u5668.u4E00u4E2Au5217u8868u6700u6D41u884Cu7684webu6D4Fu89C8u5668u5728u4E0Bu9762u53EFu4EE5u627Eu5230.<br /><br /><h1 id='goon' style='font-size:20px;cursor:pointer;'>>>>u7EE7u7EEDu8BBFu95EE</h1>"
            };
            
            
            var option = $.extend(defaults, options);
    
            
            
    
                return this.each(function(){
                    if ( $.browser.msie ) {
                        var $this = $(this);  
                        initialize($this, option.support, option.title, option.text);
                    } //if ie    
                });               
        
        };
    })(jQuery);

    方法二:

       /*iealert.js修改版源代码
     * IE Alert! jQuery plugin
     * version 1
     * author: David Nemes http://nmsdvid.com
     * http://nmsdvid.com/iealert/
     */
        (function ($) {
            //jQuery1.9+已经不在支持live方法,事件改为初始化成功后在调用bind方法绑定click事件,这样无论导入什么版本的jQuery都可以兼容
            /*$("#goon").live("click", function () {
                $("#ie-alert-overlay").hide();
                $("#ie-alert-panel").hide();
            });;*/
            var isIE = window.ActiveXObject || 'ActiveXObject' in window;//判断是否IE浏览器
            if (isIE) {
                //jQuery1.9+已经不在支持$.browser属性,可以使用IE特有条件注释来判断IE浏览器
                //使用IE条件注释判断是否IE8-浏览器
                document.write('<!--[if lt ie 9]><script>window.isIE8=true;window.showIEAlert=true</script><![endif]-->');//IE8及以下
                document.write('<!--[if lt ie 8]><script>window.isIE7=true</script><![endif]-->');//IE7及以下
                document.write('<!--[if lt ie 7]><script>window.isIE6=true</script><![endif]-->');//IE6及以下
            }
            function initialize($obj, support, title, text) {
                var panel = "<span>" + title + "</span>"
                          + "<p> " + text + "</p>"
                          + "<div class='browser'>"
                          + "<ul>"
                          + "<li><a class='chrome' href='http://www.google.cn/intl/zh-CN/chrome/browser/desktop/index.html' target='_blank'></a></li>"
                          + "<li><a class='firefox' href='http://www.mozilla.org/en-US/firefox/new/' target='_blank'></a></li>"
                          + "<li><a class='ie9' href='http://windows.microsoft.com/en-US/internet-explorer/downloads/ie/' target='_blank'></a></li>"
                          + "<li><a class='safari' href='http://www.apple.com/safari/download/' target='_blank'></a></li>"
                          + "<li><a class='opera' href='http://www.opera.com/download/' target='_blank'></a></li>"
                          + "<ul>"
                          + "</div>";
                var overlay = $("<div id='ie-alert-overlay'></div>");
                var iepanel = $("<div id='ie-alert-panel'>" + panel + "</div>");
                var docHeight = $(document).height();
                overlay.css("height", docHeight + "px");
                if (support === "ie8") {// shows the alert msg in IE8, IE7, IE6
                    //if ($.browser.msie && parseInt($.browser.version, 10) < 9) {//已经加了IE8及以下判断才会进入此函数,可以去掉这个判断
                    $obj.prepend(iepanel);
                    $obj.prepend(overlay);
                    //}
                    //if ($.browser.msie && parseInt($.browser.version, 10) === 6) {
                    if (window.isIE6) {//IE6判断,添加特殊样式进行就行修正
                        $("#ie-alert-panel").css("background-position", "-626px -116px");
                        $obj.css("margin", "0");
                    }
                } else if (support === "ie7") {     // shows the alert msg in IE7, IE6
                    //if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
                    if (window.isIE7) {
                        $obj.prepend(iepanel);
                        $obj.prepend(overlay);
                    }
                    //if ($.browser.msie && parseInt($.browser.version, 10) === 6) {
                    if (window.isIE6) {//IE6判断,添加特殊样式进行就行修正
                        $("#ie-alert-panel").css("background-position", "-626px -116px");
                        $obj.css("margin", "0");
                    }
                } else if (support === "ie6" && window.isIE6) {     // shows the alert msg only in IE6
                    //if ($.browser.msie && parseInt($.browser.version, 10) < 7) {//这个判断和if合并
                    $obj.prepend(iepanel);
                    $obj.prepend(overlay);
                    $("#ie-alert-panel").css("background-position", "-626px -116px");
                    $obj.css("margin", "0");
                    // }
                }
            }; //end initialize function
            $.fn.iealert = function (options) {
                var defaults = {
                    support: "ie7",  //IE版本支持,可以为ie8(ie8-都会显示提示),ie7(ie7-都会显示提示),ie6(ie6-都会显示提示)
                    title: "u4F60u77E5u9053u4F60u7684Internet Exploreru662Fu8FC7u65F6u4E86u5417?", // title text
                    text: "u4E3Au4E86u5F97u5230u6211u4EECu7F51u7AD9u6700u597Du7684u4F53u9A8Cu6548u679C,u6211u4EECu5EFAu8BAEu60A8u5347u7EA7u5230u6700u65B0u7248u672Cu7684Internet Exploreru6216u9009u62E9u53E6u4E00u4E2Awebu6D4Fu89C8u5668.u4E00u4E2Au5217u8868u6700u6D41u884Cu7684webu6D4Fu89C8u5668u5728u4E0Bu9762u53EFu4EE5u627Eu5230.<br /><br /><h1 id='goon' style='font-size:20px;cursor:pointer;'>>>>u7EE7u7EEDu8BBFu95EE</h1>"
                };
                var option = $.extend(defaults, options);
                return this.each(function () {
                    if (window.showIEAlert) {//条件注释判断IE8及以下才执行初始化判断
                        //if ( $.browser.msie ) {
                        var $this = $(this);
                        initialize($this, option.support, option.title, option.text);
                        $("#goon").bind("click", function () {
                            $("#ie-alert-overlay").hide();
                            $("#ie-alert-panel").hide();
                        });
                    } //if ie    
                });
            };
        })(jQuery);
  • 相关阅读:
    文件上传漏洞之js验证
    文件上传漏洞靶机upload-labs(1到10)
    URI/URL/URN都是什么
    解压jdk报错gzip: stdin: not in gzip format
    burpsuite常见问题
    C/C++字符串反转的N种方法
    转 二叉树之Java实现二叉树基本操作
    MySQL 面试基础
    转 MySQL中的行级锁,表级锁,页级锁
    MySQL问题排查工具介绍
  • 原文地址:https://www.cnblogs.com/love9happy/p/6866164.html
Copyright © 2020-2023  润新知