• ASP.NET MVC中检测浏览器版本并提示下载更新


    如果网站使用html5、css3、自适应等新特性,可能有些浏览器版本不支持。这时候,需要提醒浏览者更新浏览器的版本到最新。

    本篇用到的插件为:http://jreject.turnwheel.com/


    HomeController中:

        public class HomeController : Controller
    
        {
    
            public ActionResult Index()
    
            {
    
                return View();
    
            }
    
        }
    

    Shared/_Layout.cshtml中:

    <!DOCTYPE html>
    
    <html>
    
    <head>
    
        <meta charset="utf-8" />
    
        <meta name="viewport" content="width=device-width" />
    
        <title>@ViewBag.Title</title>
    
        @Styles.Render("~/Content/css")
    
        @RenderSection("styles", required: false)
    
        @Scripts.Render("~/bundles/modernizr")
    
        @Scripts.Render("~/bundles/jquery")
    
    </head>
    
    <body>
    
        @RenderBody()
    
        
    
         @RenderSection("scripts", required: false)
    
    </body>
    
    </html> 
    

      在Home/Index.cshtml中:

    @{
    
        ViewBag.Title = "Index";
    
        Layout = "~/Views/Shared/_Layout.cshtml";
    
    }
    
    @section styles
    
    {
    
        <link href="~/jReject/css/jquery.reject.css" rel="stylesheet" />
    
        <style type="text/css">
    
            
    
        </style>
    
    }
    
    <h2>Index</h2>
    
    @section scripts
    
    {
    
        <script src="~/jReject/js/jquery.reject.js"></script>
    
        <script type="text/javascript">
    
            $(function() {
    
                needDownloadNewExplorer();
    
            });
    
            function needDownloadNewExplorer() {
    
                setTimeout(function () {
    
                    $.reject({
    
                        reject: {
    
                            safari: true, // Apple Safari
    
                            chrome: true, // Google Chrome
    
                            firefox: true, // Mozilla Firefox
    
                            msie: true, // Microsoft Internet Explorer
    
                            opera: true, // Opera
    
                            konqueror: true, // Konqueror (Linux)
    
                            unknown: true // Everything else
    
                        },
    
                        imagePath: './jReject/images/',
    
                        browserInfo: { // Settings for which browsers to display
    
                            chrome: {
    
                                // Text below the icon
    
                                text: 'Google Chrome',
    
                                // URL For icon/text link
    
                                url: 'http://rj.baidu.com/soft/detail/14744.html',
    
                                // (Optional) Use "allow" to customized when to show this option
    
                                // Example: to show chrome only for IE users
    
                                // allow: { all: false, msie: true }
    
                            },
    
                            firefox: {
    
                                text: 'Mozilla Firefox',
    
                                url: 'http://rj.baidu.com/soft/detail/11843.html'
    
                            },
    
                            safari: {
    
                                text: 'Safari',
    
                                url: 'http://www.apple.com/safari/download/'
    
                            },
    
                            opera: {
    
                                text: 'Opera',
    
                                url: 'http://www.opera.com/download/'
    
                            },
    
                            msie: {
    
                                text: 'Internet Explorer',
    
                                url: 'http://www.microsoft.com/windows/Internet-explorer/'
    
                            }
    
                        },
    
                        closeLink: '关闭此窗口',
    
                        header: '如果本网页显示有问题,请选择下载如下浏览器的最新版本', // Header Text
    
                        paragraph1: '', // Paragraph 1
    
                        paragraph2: '',
    
                        closeMessage: '' // Message below close window link
    
                    }); // Customized Browsers
    
                }, 2000);
    
            }
    
        </script>
    
    }
    

    效果如下:

    1

  • 相关阅读:
    sql-lib闯关秘籍之1-10关
    简单的SQL注入
    五分钟带你读懂 TCP全连接队列(图文并茂)
    Ambari HDP集群搭建全攻略
    Spring Cloud Security OAuth2.0 认证授权系列(入门篇)
    敲黑板:InnoDB的Double Write,你必须知道
    重要,知识点:InnoDB的插入缓冲
    你不知道的内存知识
    每日一个知识点:关于磁盘的一些事儿
    Spring Boot 系列:日志动态配置详解
  • 原文地址:https://www.cnblogs.com/darrenji/p/4385900.html
Copyright © 2020-2023  润新知