javascript tips提示效果代碼

來源:互聯網
上載者:User
關鍵字 網頁製作 Ajax JavaScript

網頁特效 tips教程提示效果代碼

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "HTTP://www.jzread.com/tr/xhtml1/dtd/ xhtml1-transitional.dtd">


<html>


<head>


<title>網頁特效 tips提示效果代碼</title>


<style type="text/css教程">


*{ margin:0; padding:0}


#a{ width:300px; height:300px; display:none; background:#cf0; position:absolute;z-index:2}


#c div{ position:absolute;background:#c00; width:50px; height:50px;}


#c div.d1{ left:1000px;top:50px}


#c div.d2{ left:800px;top:500px}


#c div.d3{ left:10px;top:30px}


#c div.d4{ left:50px;top:650px}


#c div.d5{ left:500px;top:50px}


#c div.d6{ left:300px;top:300px}


#c div.d7{ left:1100px;top:700px}


#c div.d8{ left:300px;top:600px}


</style>


</head>


<body>


<div id="a">www.jzread.com</div>


<div id="c">


<div class="d1">www.jzread.com</div>


<div class="d2">www.jzread.com</div>


<div class="d3">www.jzread.com</div>


<div class="d4">www.jzread.com</div>


<div class="d5">www.jzread.com</div>


<div class="d6">www.jzread.com</div>


<div class="d7">www.jzread.com</div>


<div class="d8">www.jzread.com</div>


</div>


</body>


<script type="text/javascript">


function getstyle(obj,name){


 return obj.currentstyle?obj.currentstyle[name]:(document.defaultview.getcomputedstyle(obj,""). getpropertyvalue(name))


}


for(var i=0;i<document.getelementbyid("c").getelementsbytagname("div").length;i++){


 document.getelementbyid("c").getelementsbytagname("div")[i].onmouseo教程ver=function(){


  var o=document.getelementbyid("a");


  var s=document.getelementbyid("c");


 


  if(!o.style.left)o.style.left=0;


  if(!o.style.top)o.style.top=0;


 


  var ow = getstyle(o,"width");


  var oh = getstyle(o,"height");


  var sl = getstyle(this,"left");


  var st = getstyle(this,"top");


  var sw = getstyle(this,"width");


  var sh = getstyle(this,"height");


 


  ow = parseint(ow);


  oh = parseint(oh);


  sl = parseint(sl);


  st = parseint(st);


  sw = parseint(sw);


  sh = parseint(sh);


 


  var x=(x<=ow+sw+10)?360:document.documentelement.clientwidth;


  var y=(y<=oh+sh+10)?360:document.documentelement.clientheight;


 


  if(x < ow+sw){


   o.style.left = sl+sw+10 + "px"


  }else{


   o.style.left = (x-sl-10 > ow)? (sl+sw+10 + "px"):(sl-ow-10 + "px");


  }


  if(y < ow+sw){


   o.style.top = st+10 + "px"


  }else{


   o.style.top = (y-st-10 > oh)? (st+10 + "px"):(st-oh-10+sh + "px");


  }


 


  o.style.display="block";


 }


 


document.getelementbyid("c").getelementsbytagname("div")[i].onmouseout=function(e){


  var o=document.getelementbyid("a");


  o.style.display="none";


 }


}


</script>


</html>


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.