欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript實(shí)現(xiàn)動(dòng)畫(huà)打開(kāi)半透明提示層的方法

 更新時(shí)間:2015年04月21日 12:27:20   作者:休閑生活文化  
這篇文章主要介紹了JavaScript實(shí)現(xiàn)動(dòng)畫(huà)打開(kāi)半透明提示層的方法,涉及javascript操作DOM的相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JavaScript實(shí)現(xiàn)動(dòng)畫(huà)打開(kāi)半透明提示層的方法。分享給大家供大家參考。具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DOM半透明提示層</title>
<style type="text/css">
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height:25px;
line-height:25px;
text-align:center;
font-weight:bold;
border: 2px solid #849BCA;
display:block;
color:#547BC9;
float:left;
text-decoration:none;
margin-top:2px;
}
a.od:link{
background:#EEF1F8;
}
a.od:visited{
background:#EEF1F8;
}
a.od:hover{
background:#EEE;
}
a.od:active{
background:#EEE;
}
#fd{
width:500px;
height:200px;
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;
}
.content{
padding:10px;
}
</style>
</head>
<body>
<div id="bodyL">
<a href="#" class="od" onclick = "show('fd');return false;">
[打開(kāi)層]
</a>
<a href="#" class="od" onclick = "closeed('fd');return false;">
[關(guān)閉層]
</a>
</div>
<div id="fd" style="display:none;filter:alpha(opacity=100);opacity:1;">
<div class="content">移動(dòng)層</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打開(kāi)--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打開(kāi)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,200)},10);
}
}
function openy(o,y){/*--打開(kāi)y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--關(guān)閉--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打開(kāi)y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--打開(kāi)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";
}
}
/*鼠標(biāo)拖動(dòng)*/
var od = document.getElementById("fd");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e){
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function(){
mouseD = false;
odrag = "";
if(isIE)
{
od.releaseCapture();
od.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.style.opacity = 1;
}
}
//function readyMove(e){
od.onmousedown = function(e){
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.style.left = od.offsetLeft + "px";
od.style.top = od.offsetTop + "px";
if(isIE)
{
od.setCapture();
od.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
od.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e){
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.style.left = parseInt(od.style.left) +mrx + "px";
od.style.top = parseInt(od.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script><br/>
<div>http://www.dbjr.com.cn/</div>
</body>
</html>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • layui實(shí)現(xiàn)tab的添加拒絕重復(fù)的方法

    layui實(shí)現(xiàn)tab的添加拒絕重復(fù)的方法

    今天小編就為大家分享一篇layui實(shí)現(xiàn)tab的添加拒絕重復(fù)的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-09-09
  • javascript url幾種編碼方式詳解

    javascript url幾種編碼方式詳解

    下面小編就為大家?guī)?lái)一篇javascript url幾種編碼方式詳解。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-06-06
  • 改版了網(wǎng)上的一個(gè)js操作userdata

    改版了網(wǎng)上的一個(gè)js操作userdata

    改版了網(wǎng)上的一個(gè)js操作userdata,并根據(jù)其它網(wǎng)友的文章結(jié)合了下。希望對(duì)需要的朋友有所幫助。
    2007-04-04
  • ajax java 實(shí)現(xiàn)自動(dòng)完成功能

    ajax java 實(shí)現(xiàn)自動(dòng)完成功能

    都知道百度建議是用ajax做的,想要做的快速穩(wěn)定,可復(fù)制可移植就不容易了,花時(shí)間研究還不如自己來(lái)寫(xiě)。根據(jù)一個(gè)pdf文檔提供的資料,用了小半天時(shí)間,終于實(shí)現(xiàn)了。在此與大家分享
    2012-12-12
  • js將table的每個(gè)td的內(nèi)容自動(dòng)賦值給其title屬性的方法

    js將table的每個(gè)td的內(nèi)容自動(dòng)賦值給其title屬性的方法

    下面小編就為大家?guī)?lái)一篇js將table的每個(gè)td的內(nèi)容自動(dòng)賦值給其title屬性的方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-10-10
  • javascript學(xué)習(xí)隨筆(使用window和frame)的技巧

    javascript學(xué)習(xí)隨筆(使用window和frame)的技巧

    javascript學(xué)習(xí)隨筆(使用window和frame)的技巧...
    2007-03-03
  • 淺談Webpack4 plugins 實(shí)現(xiàn)原理

    淺談Webpack4 plugins 實(shí)現(xiàn)原理

    在wabpack 核心功能除了loader應(yīng)該就是plugins插件了,本文主要介紹了Webpack4 plugins 實(shí)現(xiàn)原理,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • JavaScript 中如何將秒轉(zhuǎn)換為分秒

    JavaScript 中如何將秒轉(zhuǎn)換為分秒

    JavaScript中將秒轉(zhuǎn)換為分鐘和秒,通過(guò)將秒數(shù)除以 60 得到整分鐘數(shù),獲取剩余的秒數(shù),本文通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2023-09-09
  • HTML長(zhǎng)文本截取含有HTML代碼同樣適用的兩種方法

    HTML長(zhǎng)文本截取含有HTML代碼同樣適用的兩種方法

    正如標(biāo)題所言我們可以使用CSS截?cái)嘧址篒E,FireFox,Opera ,Safari都兼容也可以使用js截取,具體實(shí)現(xiàn)如下,希望對(duì)大家有所幫助
    2013-07-07
  • JavaScript實(shí)現(xiàn)限時(shí)秒殺功能

    JavaScript實(shí)現(xiàn)限時(shí)秒殺功能

    各種電商活動(dòng)都喜換選擇限時(shí)秒殺活動(dòng)形式,這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)限時(shí)秒殺功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08

最新評(píng)論