我的页面由于处理的东西比较多 所以加载的比较慢 点击连接后半天不会有反映 所以我想 在页面没有加载完成前 显示一个<div>页面加载中....</div> 加载完成后自动将这个层隐藏 再点击连接时显示这个层 完成后隐藏层 显示加载完成后界面 但是 我不知道该怎么做 请各位帮帮忙
解决方案 »
- vs2008该如何更好的开发网站,Entity Data Model中封装了数据操作,那三层怎么用?
- 怎么样在windows server 2003 中将asp.net 网站发布到internet 上
- 请教大师,能不能把外部写的一个datatble绑定到dataset控件里?
- 1。asp.net 如何包含页面 2。GridView中有一个字段内容太长,如何截取前一段。3。asp.net ajax
- asp.net如何运行客户端脚本
- 怎么在网页上写一个播放器。虽然IE自带有一个,但是其他浏览器不支持
- asp.net网站访问异常问题求助
- 关于URL传参数的问题:
- asp.net 2.0中用户控件使用的问题
- 两个很小的问题,但我没能解决!!!!!!
- asp.net中的打印问题
- repeater里放一个table和单独一个table有什么区别
1.在你的登陆页面加一个div,用于显示loading提示。
<div id="loadwait" class="white_content">页面加载中....</div>
2.再加一个div,用于屏蔽加载时对页面的操作
<div id="loadback" class="black_overlay">CSS(效果你可以自己调,这里给个例子):
.black_overlay
{
display:none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: #dcdcdc;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content
{
display:none;
position: absolute;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 10px;
border: 10px solid orange;
background-color: White;
z-index:1002;
overflow: auto;
} 做好这些之后,在你的后台load事件最前面加上:
Page.RegisterStartupScript("aaa", "<script>ShowDiv('loadwait')</script>");
Page.RegisterStartupScript("bbb", "<script>ShowDiv('loadback')</script>");在load事件最后面加上:
Page.RegisterStartupScript("ccc", "<script>HideDiv('loadwait')</script>");
Page.RegisterStartupScript("ddd", "<script>HideDiv('loadback')</script>");JS:
//显示DIV
function ShowDiv(id)
{
var div=document.getElementById(id);
div.style.display='block';
}//隐藏DIV
function HideDiv(id)
{
var div=document.getElementById(id);
div.style.display='none';
}
<script language="JavaScript">//configure refresh interval (in seconds)
var countDownInterval=60;
//configure width of displayed text, in px (applicable only in NS4)
var c_reloadwidth=200</script>
<ilayer id="c_reload" width= && #123;c_reloadwidth}; ><layer id="c_reload2" width= && #123;c_reloadwidth}; left=0 top=0></layer></ilayer><script>var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
window.location.reload()
return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "
else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout("countDown()", 1000);
}function startit(){
if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
document.write('离下一次<a href="javascript:window.location.reload()">刷新</a>还有 <b id="countDownText">'+countDownTime+' </b>秒')
countDown()
}if (document.all||document.getElementById)
startit()
else
window.onload=startit</script>
方法:
function gotoLoading() {
$("#divMessage").click();//这里是弹出loading笼罩层,我是用的jquery的fancybox,楼主自定义吧
$.get("WebForm1.aspx", function(data) {
window.location = "WebForm1.aspx"; //这里是加载成功执行的方法 });
}
在你的超链接上调用即可
低一个div设置成显示的,第二个设置成隐藏的。然后在</html>刚刚加载完之前用javas吧第一个设置成隐藏,第二个设置成显示就成了。但是没必要那么复杂直接在aspx页面插入css和JavaScript代码就成了。
<html>
<body>
<div id="loading" style="display: block;">加载中</div>
<div id="content" style="display: none;">
large text.........................................
</div>
<script language="javascript">
var loading = document.getElementById("loading");
var content = document.getElementById("content");
loading.style.display = "none";
content.style.display = "block";
</script>
</body>
</html>
function startDelay(str)
{
var t;
t=setTimeout("startTask()",300);
document.getElementById("<%=hide.ClientID %>").value=str;
return true;
}
function startTask()
{
window.location= document.getElementById("<%=hide.ClientID %>").value;
var lo=document.getElementById("logon");
var lg=document.getElementById("backloading");
lg.style.display="block";
lo.style.display="block";
return true;
}
function onTaskCompleted()
{ var lo=document.getElementById("logon");
lo.style.display="none";
var lg=document.getElementById("backloading");
lg.style.display="none";
}
</script>
<div id="backloading" style="display:none;width:100%;height:2000px;position:absolute;z-index:1000;border:0px;background-color:#cccccc;margin:0px;padding:0px;filter:alpha(opacity=50);"align="center"></div>
<!--弹出层显示内容-->
<div id="logon" align="center" style=" text-align:center;display:none;background-color:#ffffff;position:absolute;border:3px solid #ffffff; left: 400px; top: 270px; z-index:1001">
<div>
<div> <h5> <asp:Image ID="Image2" runat="server" ImageUrl="~/images/loading.gif" style="z-index:1002" /></h5> </div>
<div>数据正在加载,请稍候.....</div>
</div>
</div>
然后在超链接上或按钮上调用startDelay(str)就行了 非常好用