层顶不了事,你是框架页面,页面里的层不太好跨框架且也管不住页面里的链接;用模态框吧,多出一个页面,且处理起来比较麻烦些且还有兼容性问题。另辟蹊径:
<script>
document.onclick=function(event)
{
var e=window.event || e; e=e.srcElement || e.target;
if(e.tagName=="A" && e.href)
{
document.body.disabled=true;
setTimeout("document.body.disabled=false;", 3000); //毫秒
}
}
</script>
<div>ddd</div>
<a href="http://blog.csdn.net/meizz/" target="_blank">hehe</a>用 disabled 方法使页面里的所有链接“失效”一段时间,避免过快的重复点击!
<script>
document.onclick=function(event)
{
var e=window.event || e; e=e.srcElement || e.target;
if(e.tagName=="A" && e.href)
{
document.body.disabled=true;
setTimeout("document.body.disabled=false;", 3000); //毫秒
}
}
</script>
<div>ddd</div>
<a href="http://blog.csdn.net/meizz/" target="_blank">hehe</a>用 disabled 方法使页面里的所有链接“失效”一段时间,避免过快的重复点击!
<script>
document.onclick=function(event)
{
var e=window.event || e; e=e.srcElement || e.target;
if(e.tagName=="A" && e.href)
{
document.getElementById("lock").style.display="";
setTimeout("document.getElementById('lock').style.display='none'", 3000); //毫秒
}
}
</script>
<div id="lock" style="
width: 100%;
height: 100%;
z-index: 8888;
display: none;
position: absolute;
background-image: url(http://community.csdn.net/Tree/TreeImages/l5.gif);
"> </div>通过这种方法锁定的页面,用户感觉没有上面那种disabled强烈。效果不错。
// JavaScript Document
/**
* 功能:显示提示窗口
* 作者:申楠 qq:38371354 email:[email protected] http;//amushen.cnblogs.com
* 日期:2005-10-25
* 版本:1.0
* 备注:版权没有,随便拷贝,如果用于商业应用请通知本人,同时保留这段注释。
*
* 使用方法提示:
*/ /**
* 描述:显示提示层
* 作者:申楠
* 参数: 显示信息内容
* 返回: 无
* 日期:2005-10-25
*/
var ifm=null;
function showPop(info){
if(ifm==null){
ifm=document.createElement("<iframe allowTransparency='true' id='popframe' frameborder=0 marginheight=0 src='about:blank' marginwidth=0 hspace=0 vspace=0 scrolling=no></iframe>")
ifm.style.width=screen.availWidth;
ifm.style.height=screen.availHeight;
ifm.style.position="absolute";
ifm.style.left=0;
ifm.style.top=0;
ifm.name=ifm.uniqueID;
document.body.appendChild(ifm);
}else{
ifm.style.visibility="visible";
}
var win=window.frames[ifm.name];
win.document.write("<body leftmargin=0 topmargin=0 oncontextmenu='self.event.returnValue=false'><div id=popbg></div><div id=popbody></div></body>");
win.document.body.style.backgroundColor="transparent";
document.body.style.overflow="hidden";
var pBody=win.document.body.children[1];
var pBg=win.document.body.children[0];
hideAllSelect();
initBg(pBg);
initBody(pBody,info);
}
/**
* 描述:初始化背景层
* 作者:申楠
* 参数: obj;背景层
* 返回: 无
* 日期:2005-10-25
*/
function initBg(obj){
with(obj.style){
position="absolute";
left="0";
top="0";
width="100%";
height="100%";
visibility="hidden";
backgroundColor="#333333";
filter="blendTrans(duration=1) alpha(opacity=60)";
}
if (obj.filters.blendTrans.status != 2) {//no playing
obj.filters.blendTrans.apply();
obj.style.visibility="visible";
obj.filters.blendTrans.play();
}
}
/**
* 描述:初始化显示层
* 作者:申楠
* 参数: obj;显示层;info:显示内容;winName :the name of the iframe
* 返回: 无
* 日期:2005-10-25
*/
function initBody(obj,info){
with(obj.style){
position="absolute";
width="400";
height="150";
backgroundColor="#ffffff";
}
obj.style.left=window.document.body.clientWidth/2-200;
obj.style.top=window.document.body.clientHeight/3;
var str;
str="<table border=0 cellpadding=0 cellspacing=1 bgcolor=#000000 width=100% height=100%><tr height=20>";
str+="<td align=center style='color:#000000;font-size:14px;font-weight:bold' bgcolor=#9999ff>...:::提示:::...</td></tr>";
str+="<tr><td align=center bgcolor=#efefff style='font-size:12px;color:#000000;vertical-align: bottom;'>";
str+=info+"<br><br><button onclick='parent.closeWin()'>确定</button><br><br></td></tr></table>";
obj.innerHTML=str;
}
/**
* 描述:关闭一切
* 作者:申楠
* 参数: obj :the iframe 's name
* 返回: 无
* 日期:2005-10-25
*/
function closeWin(){
ifm.style.visibility="hidden";
showAllSelect();
document.body.style.overflow="auto";
}
/**
* describe:hide all select
* author:shennan
* params:
* return:
* date:2005-10-25
*/
function hideAllSelect(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="hidden";
}
function showAllSelect(){
var obj;
obj=document.getElementsByTagName("SELECT");
var i;
for(i=0;i<obj.length;i++)
obj[i].style.visibility="visible";
}</script>
<body>
<button onClick="showPop('今天天气真好呀')">test</button>
<button onClick="showPop('今天天气真好呀')">test</button>
</body>
给你一个 filter cross browser 写法吧:opacity: 0.6;
-moz-opacity: 0.6;
-khtml-opacity: 0.6;
filter:alpha(opacity=60);
作者:申楠呵呵,这个是你么?
本家呀!
<button onClick="showPop('今天天气真好呀')" onfocus="this.blur();">test</button>