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 Safarichrome: true, // Google Chromefirefox: true, // Mozilla Firefoxmsie: true, // Microsoft Internet Exploreropera: true, // Operakonqueror: true, // Konqueror (Linux)unknown: true // Everything else},imagePath: './jReject/images/',browserInfo: { // Settings for which browsers to displaychrome: {// Text below the icontext: 'Google Chrome',// URL For icon/text linkurl: '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 Textparagraph1: '', // Paragraph 1paragraph2: '',closeMessage: '' // Message below close window link}); // Customized Browsers}, 2000);}</script>}
效果如下:

ASP.NET MVC中检测浏览器版本并提示下载更新的更多相关文章
- 如何:在 ASP.NET 网页中检测浏览器类型
https://msdn.microsoft.com/zh-cn/library/3yekbd5b(VS.80).aspx private void Button1_Click(object send ...
- Ext.Net学习笔记24:在ASP.NET MVC中使用Ext.Net
在前面的笔记中已经介绍了如何在ASP.NET WebForm中使用Ext.Net,由于这个系列一直在WebForm中使用,所以并没有涉及到ASP.NET MVC中的用法. 如果你要在ASP.NET M ...
- .net 开源模板引擎jntemplate 教程:基础篇之在ASP.NET MVC中使用Jntemplate
在ASP.NET MVC 中使用Jntemplate 上一篇我们详细介绍了jntemplate的标签语法,本篇文章将继续介绍如何在ASP.NET MVC 中使用Jntemplate. 一.使用Jnte ...
- asp.net mvc 中[Authorize]在IE9以上版本关于FormsAuthentication.SetAuthCookie无效的问题 解决方案
简单的解决方法是,在网站根目录,新增一个浏览器定义文件(browser definition file) 叫“App_Browsers”文件夹,然后里面放一个“IE10.browser”文件即可,网站 ...
- 如何在 ASP.NET MVC 中集成 AngularJS(3)
今天来为大家介绍如何在 ASP.NET MVC 中集成 AngularJS 的最后一部分内容. 调试路由表 - HTML 缓存清除 就在我以为示例应用程序完成之后,我意识到,我必须提供两个版本的路由表 ...
- 如何在 ASP.NET MVC 中集成 AngularJS(2)
在如何在 ASP.NET MVC 中集成 AngularJS(1)中,我们介绍了 ASP.NET MVC 捆绑和压缩.应用程序版本自动刷新和工程构建等内容. 下面介绍如何在 ASP.NET MVC 中 ...
- 如何在 ASP.NET MVC 中集成 AngularJS(1)
介绍 当涉及到计算机软件的开发时,我想运用所有的最新技术.例如,前端使用最新的 JavaScript 技术,服务器端使用最新的基于 REST 的 Web API 服务.另外,还有最新的数据库技术.最新 ...
- Asp.Net MVC 中的 Cookie(译)
Asp.Net MVC 中的 Cookie(译) Cookie Cookie是请求服务器或访问Web页面时携带的一个小的文本信息. Cookie为Web应用程序中提供了一种存储特定用户信息的方法.Co ...
- 【ASP.NET MVC系列】浅谈jqGrid 在ASP.NET MVC中增删改查
ASP.NET MVC系列文章 [01]浅谈Google Chrome浏览器(理论篇) [02]浅谈Google Chrome浏览器(操作篇)(上) [03]浅谈Google Chrome浏览器(操作 ...
随机推荐
- linux服务器如何添加sudo用户
1. 编辑 vi /etc/ssh/sshd_config 文件,修改默认端口:默认Port为22,并且已经注释掉了,修改是把注释去掉,并修改成其它的端口. 原来用默认端口:22修改为:8975 (这 ...
- vue之给a标签赋值
<li v-for="(bp,index) in bpLists"> <a class="bidPublicityTitle" :href=& ...
- Mockito 简明教程
什么是 Mock 测试 Mock 测试就是在测试过程中,对于某些不容易构造(如 HttpServletRequest 必须在Servlet 容器中才能构造出来)或者不容易获取比较复杂的对象(如 JDB ...
- extjs6入门:用sencha cmd搭建简单的extjs6项目
开发准备 1.sencha cmd安装 2.extjs6.0.0 gpl正式版下载,地址:https://www.sencha.com/legal/gpl/ ,解压ext-6.0.0-gpl.zip ...
- Servlet 3.0 新特性详解
转自:http://www.ibm.com/developerworks/cn/java/j-lo-servlet30/#major3 Servlet 是 Java EE 规范体系的重要组成部分,也是 ...
- explain的使用
MySQL 提供了一个 EXPLAIN 命令, 它可以对 SELECT 语句进行分析, 并输出 SELECT 执行的详细信息, 以供开发人员针对性优化. mysql. row ************ ...
- 【BZOJ】4361: isn
题解 可以想一下保留一个长度为k的不降序列方案数是\(f[k] (n - k)!\) \(f[k]\)是有多少个长度为k的不降序列 我们去掉不合法的,一定是前一次操作的时候有一个长度为\(k + 1\ ...
- 关于 Google 与 Chrome
不断更新... 查看chrome版本 chrome浏览器中输入 chrome://version/ Chrome吧 :http://tieba.baidu.com/f?kw=chrome&i ...
- SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms.
SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录
0.目录 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.感谢 在此感谢.net ...