JS之弹出说明框

 

一、函数说明  

  1. <script language=javascript>
  2.       var p=window.createPopup();
  3.      function showComment(comment,id)//显示说明框
  4.      {
  5.                 p.document.body.style.backgroundColor="red";
  6.                 p.document.body.style.border=" 1px";
  7.                 p.document.body.innerHTML=comment;
  8.                 p.show(0,0,200,50,document.getElementById(id));
  9.        }
  10.        function closeComment()//关闭说明框
  11.       {
  12.              p.show(0,0,0,0,document.getElementById("comment"));//此处只要前四个参数全为0就可以,最后一个可以随便写。
  13.       }
  14.     </script>

    在项目中,有时为了界面友好,我们可以使用弹出说明框的形式来提示用户。

    如下图所示:

        鼠标未移至链接处:

                            

        鼠标移至链接处:

                            

二、源码如下:

  

  1. <html>
  2.     <head>
  3.         <title>test</title>
  4.         <script language=javascript>
  5.             var p=window.createPopup();
  6.             function showComment(comment,id)
  7.             {
  8.                 //var p=window.createPopup();
  9.                 p.document.body.style.backgroundColor="red";
  10.                 p.document.body.style.border=" 1px";
  11.                 p.document.body.innerHTML=comment;
  12.                 p.show(0,0,200,50,document.getElementById(id));
  13.             }
  14.             function closeComment()
  15.             {
  16.                 p.show(0,0,0,0,document.getElementById("comment"));
  17.             }
  18.         </script>
  19.         
  20.     </head>
  21.     <body>
  22.         <a href="http://www.baidu.com"  οnmοuseοver="showComment('This a Comment !','comment')" οnmοuseοut="closeComment()">This a Comment</a><span id="comment"> </span>
  23.     </body>
  24. </html>

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值