WEB开发中的提示
1.当后台处理时间较长时,可在提交前显示一个层提示 :
<script type='text/javascript' src='DivLayer.js'></script> <script type='text/javascript' > function submitXform() { var params = {width:300,height:60}; var layer = new Layer(params); layer.showStringLayer("正在检查并提交,请稍等..."); inputForm.submit(); } </script>
2.当加载页面需要较长时间时,可使用如下方式提示:
<body> <script type='text/javascript' src='DivLayer.js'></script> <script type='text/javascript' > var params = {width:300,height:60}; var layer = new Layer(params); layer.showStringLayer("正在加载页面,请稍等..."); </script> </body> <script type='text/javascript' > setInterval("doInit()",100); function doInit() { var currentState = document.readyState.toLowerCase(); if (currentState == 'complete') // 文档加载完成 { // 隐藏提示层 layer.hideLayer(); } } </script>
DivLayer.js:
//居中显示的层 var Layer = function(params){ this.params = params; this.createLayer = function() { var s = "<div id='center_layer' style='position:absolute;top:50%;left:50%;text-align:center;width:" + this.params.width +";height:"+this.params.height+";margin-top:-"+this.params.height/2+";margin-left:-"+this.params.width/2+";padding-top:"+(this.params.height/4+5)+";z-index:10;display:none;border:1px solid #0099FF;'></div>"; var fullscreen = "<div style='width:100%;height:100%;z-index=9'></div>"; document.write(fullscreen); document.write(s); }, this.showStringLayer = function(displayString) { this.createLayer(); center_layer.innerText = displayString; center_layer.style.display = "block"; }, this.showImageLayer = function(img) { this.createLayer(); center_layer.innerHTML = img; center_layer.style.display = 'block'; }, this.hideLayer = function() { center_layer.style.display = 'none'; } }
相关推荐
chenhaotao 2020-11-13
liaochaowu 2020-11-12
sjcheck 2020-11-10
huangliuyu00 2020-10-29
PncLogon 2020-09-24
杏仁技术站 2020-09-18
fubrty 2020-09-08
颤抖吧腿子 2020-09-04
liangjielaoshi 2020-08-19
viewerlin 2020-08-19
hfuturer 2020-08-16
Lzs 2020-08-14
一青年 2020-08-13
SHINESUNNY 2020-08-11
lantingyue 2020-07-30
RainyX 2020-07-26
adentheima 2020-07-25
JessePinkmen 2020-07-19