<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> 背景变灰并不可编辑 </TITLE>
<style type="text/css">
<!--
html,body{
height:100%;
}
#fd {
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:2px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;/*filter:alpha(opacity=50);*/
z-index: 10;
}
a.od {
float:right;
font-size:14px;
color: #CC0000;
text-decoration: none;
}
-->
</style>
</HEAD>
<BODY>
<div id="bodyL"> <a href="#" onclick = "show('fd',event,this);return false;"> [打开层] </a> </div>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="contentup"> <a href="#" class="od" onclick = "closeed('fd');return false;"> 关 闭 </a><br/>
2007年12月13日 ... clearInterval类似JS的clearTimeout. 时间间隔可以用setInterval 命令来创建并用clearInterval 命令来终止。setInterval 所用的参数有两种格式。- <a href='http://www.agrilink.cn/'>中国农业</a>
</div>
<script type="text/javascript">
var prox,proy,proyc,proxc,isIeOs,height;
var isIe=(document.all)?true:false;
function show(id,ev,obj){/*--打开--*/
isIeOs = getOs()=="Firefox"?false:true;
height = isIeOs?1:0;
closeWindow();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.documentElement.scrollHeight)<592?592:parseInt(document.documentElement.scrollHeight);
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";
back.style.cssText=styleStr;
document.body.appendChild(back);
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = height+"px"; //ie6\7不支持0px.ff3.0.x/3.5.x支持
o.style.top = obj.offsetTop + "px";
o.style.left = obj.offsetLeft + 80 + "px";
prox = setInterval(function(){openx(o,500)},50);//setInterval函数会重复间隔一段时间执行代码,因此应使用clearInterval函数将其停止.500是x坐标的宽度
}
function openx(o,x){/*--每隔50毫秒延伸一次x坐标--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,300)},50);//300是y坐标的高度
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
//关闭窗口
function closeWindow(){
if(document.getElementById('back')!=null){
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
}
function closeed(id){/*--关闭--*/
closeWindow();
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
//o.style.display = "none";
proyc = setInterval(function(){closey(o)},50);
}
}
function closey(o){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy > height)
{
cy = cy - Math.ceil(cy/5);
o.style.height = cy +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},50);
}
}
function closex(o){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
//判断是IE还是FF
function getOs(){
var OsObject = "";
if(navigator.userAgent.indexOf("MSIE")>0) {
return "MSIE";
}
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
return "Firefox";
}
if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
return "Safari";
}
if(isCamino=navigator.userAgent.indexOf("Camino")>0){
return "Camino";
}
if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
return "Gecko";
}
}
</script>
</BODY>
</HTML>