asp.net 因某段代码执行时间较长,所以想实现像登录中界面变灰,html点击弹出登录界面“请稍等”字样的界面

ylw6006 的BLOG
用户名:ylw6006
文章数:232
评论数:731
访问量:1811474
注册日期:
阅读量:5863
阅读量:12276
阅读量:409481
阅读量:1097680
51CTO推荐博文
本文转载自,感谢作者分享!
Web服务器下设置变灰的方法比较简单,总结如下:
1、安装mod_ext_filter模块(此模块用来在所有的输出页面插入你想要的内容,比如css,广告头之类)
这里假设apache已经在运行,因此不需要重新编译apache,只新增mod_ext_filer模块。
cd httpd-2.2.15/modules/filters
apxs -cia mod_ext_filter.c
2、修改httpd.conf
1)定义过滤器(filter)的名字(这里为graypage)和配置filter要调用程序的名字(graypage.pl)
ExtFilterDefine graypage mode=output intype=text/html cmd=&/usr/local/bin/graypage.pl&
2)Directory添加SetOutputFilter graypage,添加后完整的配置类似下面这样:
SetOutputFilter表示对所有输出使用过滤器
Options Indexes FollowSymLinks
AllowOverride All
SetOutputFilter graypage
Order allow,deny
Allow from all
/var/www/htdocs为DocumentRoot的路径。
3.创建/usr/local/bin/graypage.pl,内容如下:
#!/usr/bin/perl
my @lines = &STDIN&;
open GRAYLINE, &/var/www/htdocs/gray-css.txt& or die &cant't find the css file.&;
my @graylines = &GRAYLINE&;
print @lines,@
注意加上可执行权限:chmod +x /usr/local/bin/graypage.pl
注:/var/www/htdocs/假设为documnentroot路径。
4.创建/var/www/htdocs/gray-css.txt,内容如下:
&style type=&text/css&&html {filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); }&/style&
这段代码是使IE类浏览器变灰的CSS。(Firefox下无效)
5.重启Apache
apachectl graceful
很多站点是租用的服务器,可能没有权限修改web服务器,那么可以简单的在css文件(如果有全局css最好,比如WordPress的style.css)最后加入
html{filter:}
除非是全局css,否则只会让某个页面变灰,而不能实现直接修改web服务器那样让所有页面都变灰。
了这篇文章
类别:┆阅读(0)┆评论(0)3540人阅读
Asp.Net(330)
最近在网上看到一篇文章,讲ASP.NET ajax中的异常处理,有一部分是自定义javascript处理异常。突然想到网易邮箱中,弹出对话框,后边的页面变灰且不可点击的效果。
在网上找了一下,实现方法就是用两个层,一个层用来显示提示信息,一个层用来遮住页面;还有一个办法就是用iframe.两者的不同之处大概就在于iframe可以遮住全部的页面元素,而div则不能遮住下拉列表。
我这个例子使用的div,绝大部分引用了:/Terrylee/archive//Customizing_Error_Handling.html
代码如下:
Default.aspx 前台页面及javascript
&%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&&&!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&&html xmlns="http://www.w3.org/1999/xhtml"&&head runat="server"&&& &&title&Untitled Page&/title&&& &&style type="text/css"&&& &#UpdatePanel1{&& & &width: 200 height: 50&& & &border: solid 1&& &}&& &#AlertDiv{&& &left: 40%; top: 40%;&& &position: width: 200&& &padding: 12 && &border: #&& &background-color: && &text-align:&& &visibility:&& &z-index: 99;&& &}&& &&& &#AlertButtons{&& &position: right: 5%; bottom: 5%;&& &}&/style&&/head&&body id="bodytag" style="margin: 0px"&&& &&form id="form1" runat="server"&&& & & &&asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" /&&&& & & &&script type="text/javascript"&var divElem = 'AlertDiv';var messageElem = 'AlertMessage';var bodyTag = 'bodytag';var sWidth,sH && &sWidth=document.body.offsetW//浏览器工作区域内页面宽度 && &sHeight=screen.//屏幕高度(垂直分辨率) &&&& &//背景层(大小与窗口有效区域相同,即当弹出对话框时,背景显示为放射状透明灰色) && &var bgObj=document.createElement("div");//创建一个div对象(背景层) && &//定义div属性,即相当于 && &// &div id="bgDiv" style="position: top:0;
background-color:#777;
filter:progid:DXImagesTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75);
opacity:0.6; left:0; width:918 height:768
z-index:19999;"&&/div& && &bgObj.setAttribute('id','bgDiv'); && &bgObj.style.position= "absolute";&& &bgObj.style.display="none";&& &bgObj.style.top= "0"; && &bgObj.style.background= "#777";&& &bgObj.style.filter= "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)"; && &bgObj.style.opacity= "0.6"; && &bgObj.style.left= "0"; && &bgObj.style.width=sWidth + "px"; && &bgObj.style.height=sHeight + "px"; && &bgObj.style.zIndex = "10000"; && &$get(bodyTag).appendChild(bgObj);&Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);function ToggleAlertDiv(visString){&& & if (visString == 'hidden')&& & {& && & & & $get('bgDiv').style.display="none";&& & & & $get(bodyTag).style.backgroundColor = 'white';&& & }&& & else&& & {&& & & & $get('bgDiv').style.display="";&& & }&& & var adiv = $get(divElem);&& & adiv.style.visibility = visS}&function ClearErrorState() {&& & $get(messageElem).innerHTML = '';&& & ToggleAlertDiv('hidden');}&function EndRequestHandler(sender, args){&&& if (args.get_error() != undefined)&& {&& & & var errorM&&& & & if (args.get_response().get_statusCode() == '200')&& & & {&& & & & & errorMessage = args.get_error().&& & & }&& & & else&& & & {&& & & & & errorMessage = 'An unspecified error occurred. ';&& & & }&& & & args.set_errorHandled(true);&&& & & ToggleAlertDiv('visible');&&& & & $get(messageElem).innerHTML = errorM&& }}&& & & &&/script&&&& & & &&div&&& & & & & &&asp:UpdatePanel ID="UpdatePanel1" runat="server"&&& & & & & & & &&ContentTemplate&&& & & & & & & & & &&asp:TextBox ID="TextBox1" runat="server" Width="30px"&&/asp:TextBox&&& & & & & & & & & &/&asp:TextBox ID="TextBox2" runat="server" Width="30px"&&/asp:TextBox&&&asp:Button&& & & & & & & & & & & &ID="Button1" runat="server" OnClick="Button1_Click" Text="Execute" /&&& & & & & & & & & &&asp:Label ID="Label1" runat="server" Text="Label"&&/asp:Label&&& & & & & & & &&/ContentTemplate&&& & & & & &&/asp:UpdatePanel&&& & & & & &&div id="AlertDiv" style="z-index: 20000;"&&& & & & & & & &&div id="AlertMessage"&&& & & & & & & &&/div&&& & & & & & & &&br /&&& & & & & & & &&div id="AlertButtons"&&& & & & & & & & & &&input id="OKButton" type="button" value="OK" runat="server" onclick="ClearErrorState()" /&&& & & & & & & &&/div&&& & & & & &&/div&&& & & &&/div&&& &&/form&&/body&&/html&
Default.aspx.cs 后台页面
using Susing System.Dusing System.Cusing System.Wusing System.Web.Susing System.Web.UI;using System.Web.UI.WebCusing System.Web.UI.WebControls.WebPusing System.Web.UI.HtmlC&public partial class _Default : System.Web.UI.Page{&& &protected void Page_Load(object sender, EventArgs e)&& &{&&& &}&& &protected void Button1_Click(object sender, EventArgs e)&& &{&& & & &try&& & & &{&& & & & & &int a = Int32.Parse(TextBox1.Text);&&& & & & & &int b = Int32.Parse(TextBox2.Text);&&& & & & & &int res = a /&&& & & & & &Label1.Text = res.ToString();&& & & &}&&& & & &catch (Exception ex)&& & & &{&& & & & & &if (TextBox1.Text.Length & 0 && TextBox2.Text.Length & 0)&& & & & & &{&& & & & & & & &ex.Data["ExtraInfo"] = " You can't divide " +&&& & & & & & & & & &TextBox1.Text + " by " + TextBox2.Text + ".";&&& & & & & &}&& & & & & &&& & & &}&& &}&& &protected void ScriptManager1_AsyncPostBackError(object sender, AsyncPostBackErrorEventArgs e)&& &{&& & & &if (e.Exception.Data["ExtraInfo"] != null)&& & & &{&& & & & & &ScriptManager1.AsyncPostBackErrorMessage =&&& & & & & & & &e.Exception.Message +&&& & & & & & & &e.Exception.Data["ExtraInfo"].ToString();&&& & & &}&& & & &else&& & & &{&& & & & & &ScriptManager1.AsyncPostBackErrorMessage =&&& & & & & &"An unspecified error occurred.";&& & & &}&& &}}
ok!本章到此结束!
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4318863次
积分:55857
积分:55857
排名:第43名
原创:1175篇
转载:567篇
评论:1063条
(1)(4)(2)(2)(1)(1)(2)(1)(1)(3)(3)(1)(5)(1)(2)(3)(3)(4)(6)(8)(12)(3)(7)(1)(2)(8)(5)(2)(2)(1)(2)(2)(10)(9)(9)(2)(12)(10)(3)(6)(4)(3)(4)(16)(5)(12)(12)(7)(20)(25)(24)(10)(7)(4)(2)(4)(34)(12)(2)(6)(6)(1)(2)(4)(1)(8)(28)(9)(3)(3)(3)(5)(4)(2)(5)(2)(2)(3)(2)(1)(3)(3)(3)(2)(3)(2)(16)(7)(4)(10)(3)(8)(10)(11)(47)(151)(158)(11)(12)(47)(16)(16)(87)(71)(65)(164)(89)(61)(14)(10)(12)(19)(6)(5)(18)(14)(21)(11)(31)(20)(30)(4)(2)(1)(6)网站变灰代码 兼容主流浏览器 为灾区祈祷
首先,为雅安地震灾区遇难同胞默哀!
今天有很多网站的首页都变灰了,我们也找了很多变灰的方法,但是网上的大部分都不能够实现现在浏览器的兼容问题。这里我们找到一个CSS和一个JS代码,可以同时支持除IE10(我这边测试不变会)以为其它浏览器,IE6、IE7、IE8、IE9、谷歌浏览器、Opera、猎豹浏览器、360浏览器、傲游浏览器等主流浏览器。
下面这段代码支持IE6到IE9和谷歌内核浏览器:
html{filter: grayscale(100%);-webkit-filter: grayscale(100%);-moz-
filter: grayscale(100%);-ms-filter: grayscale(100%);-o-filter: grayscale(100%);
filter: url("data:image/svg+utf8, filter: url("data:image/svg+utf8, \'grayscale\'& \'grayscale\'& 0.3 0 0 0.3 0. 0 0 0 1 0\'/& #grayscale");
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter:&
grayscale(1);}
html{filter: grayscale(100%);-webkit-filter: grayscale(100%);-moz-
filter: grayscale(100%);-ms-filter: grayscale(100%);-o-filter: grayscale(100%);
filter: url("data:image/svg+utf8,\'grayscale\'&0.3 0 0 0.3 0. 0 0 0 1 0\'/&#grayscale");
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter:&
grayscale(1);}
另外Opera浏览器貌似不可以,就需要用到这段JS代码:
直接复制就可以用的,这两段代码基本上兼容了现在大部分浏览器,比那些其它的被复制了N遍的老代码好多了!效果展示:/
最新图文推荐
最新专栏文章
大家感兴趣的内容
网友热评的文章
seajs.config({
base: "/resource/passapi/scripts/"
seajs.use('seajs/seajs-css');
seajs.use(['artdialog/src/dialog-plus'], function (dialog) {
$('#favorite').on('click', function(){
$.getJSON('/passapi.ashx?op=userstatus&callback=?', function(data){
if (data.status == 1) {
var _this = $('#favorite').find('span');
$.getJSON('/?app=favorite&controller=favorite&action=add&jsoncallback=?&contentid='+contentid, function(json){
if(json.state){
_this.html('}

我要回帖

更多关于 校园网不弹出登录界面 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信