您现在的位置:多问网知识中心电脑教学网页设计仿QQ聊天窗口中点击链接出现提示效果的方法

仿QQ聊天窗口中点击链接出现提示效果的方法

06-11 19:38:38   浏览次数:61826  栏目:网页设计
标签:网页设计教程,网页设计知识,http://www.duowen123.com 仿QQ聊天窗口中点击链接出现提示效果的方法,

    在QQ聊天窗口中,当好友发送给我们一个网址链接时,将鼠标移到链接上时,会出现一个提示框,提示我们是打开、复制还是举报。其实在网页中我们也可以做出这样的效果,今天就教大家实现仿QQ聊天窗口中点击链接出现提示效果的方法。

    具体的效果如下图所示:

    相关代码如下所示:

<!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>仿QQ聊天窗口中点击链接出现提示效果的方法-HTMer.Com</title>
<script language="JavaScript" type="text/javascript">
function S(i){return document.getElementById(i)}
function copyUrl(){ //复制网址
var clipBoardContent=S("downloadDirect").href;
  try{
    window.clipboardData.setData("Text",clipBoardContent);
    alert("此网址已经复制到剪贴板。");
  }catch(e){
    alert("复制不成功,请在IE浏览器下复制。");
  }
}
document.onclick = function(evt){ //在不是链接的位置单击时,隐藏显示的层
var _target = evt ? evt.target : event.srcElement ;
var _id = _target.id;
if( _id == "" ){
_id = _target.tagName;
}
if( _id !="A"){
S("downloadPanel").style.display = 'none';
}
}
window.onload=function(){ //网页载入时,绑定指定对象下的所有a
  var htmer=S("htmer");
  var htmer1 = htmer.getElementsByTagName("a");
  for(var i=0,j=htmer1.length; i<j; i++){
    htmer1[i].onclick=function(evt){
      var _event = evt ? evt : window.event;
      var _target = evt ? evt.target : window.event.srcElement;
      var _p = S("downloadPanel");
      _p.style.top = _event.clientY + document.body.scrollTop ;
      _p.style.left = ( _event.clientX + document.body.scrollLeft < 160 ? _event.clientX + document.body.scrollLeft + 10  : _event.clientX  + document.body.scrollLeft - 120 );
      S("downloadPanel").style.display = '';
      S("downloadDirect").href= this.href;
      return false;
    }
  }
}
</script>
<style type="text/css">
html,body{ font-size:12px;}
a {color:#0000FF;text-decoration:underline;cursor:pointer;}
.pointer {cursor:pointer;}
.infobar {background:#EAF9FF;border:1px solid #1D5CBB;color:#0000FF;margin-bottom:10px;padding:8px 20px 4px 20px;}
</style>
</head>
<body>
<div id="downloadPanel" style="position:absolute;top:0px;left:0px;width:160px;z-index:999;padding:6px 2px 6px 10px;border:1px solid #1D5CBB;display:none;" class="infobar">
<div style="padding:3px 0 0 0;"><a id="downloadDirect" href="javascript:void(0);" target="_blank">打开网址</a>  <a id="downloadAgent" href="javascript:void(0);" onClick="copyUrl()">复制</a>  <a href="javascript:void(0)" onClick="S('downloadPanel').style.display = 'none';">关闭</a></div>
</div>
<div id="htmer">
  <p><a href="http://www.duowen123.com">http://www.duowen123.com</a></p>
  <p><a href="http://htmer.com">http://htmer.com</a></p>
</div>
</body>
</html>,仿QQ聊天窗口中点击链接出现提示效果的方法
相关热词搜索: tag: 网页设计,网页设计教程,网页设计知识,电脑教学 - 网页设计
上一篇:在网页中使用google字体的方法(Google Font API)
文章评论
联系我们 | 网站地图 | 范文大全 | 管理资料 | 驾照考试 | 教学资料 | 名言大全 | 软件下载
Copyright @ 多问网 all rights reserved
学生评语_教案设计_小学语文试卷
1 2 3 4 5 6 7 8 9 10 11 12