首页 > 语言 > JavaScript > 正文

javascript简单实现类似QQ头像弹出效果的方法

2024-05-06 16:24:14
字体:
来源:转载
供稿:网友

这篇文章主要介绍了javascript简单实现类似QQ头像弹出效果的方法,可实现简单的页面元素弹出效果,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了javascript简单实现类似QQ头像弹出效果的方法。分享给大家供大家参考。具体实现方法如下:

 

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  6. <title>简单的类似QQ头像的弹出效果</title> 
  7. <style type="text/css"
  8. #oimg{float:left; margin:10px} 
  9. #msg{border:solid; width:300px;height:250px;display:none;float:left;padding:10px} 
  10. </style> 
  11. </head> 
  12. <body> 
  13. <img id="oimg" src="images/show.jpg" /> 
  14. <div id="msg">啦啦啦啦。。。。。</div> 
  15. <script type="text/javascript"
  16. var oid=document.getElementById('oimg'); 
  17. var omsg=document.getElementById('msg'); 
  18. var timer=null
  19. oid.onmousemove=showMsg; 
  20. oid.onmouseout=hideMsg; 
  21. omsg.onmouseout=hideMsg; 
  22. omsg.onmousemove=function(){clearTimeout(timer)}; 
  23. function showMsg(){if(timer){clearTimeout(timer)}omsg.style.display='block';} 
  24. function hideMsg(){timer=setTimeout(function(){omsg.style.display='none';},500);} 
  25. </script> 
  26. </body> 
  27. </html> 

希望本文所述对大家的javascript程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选