当前位置:学学看123知识中心电脑教学网页设计仿QQ聊天窗口中点击链接出现提示效果的方法» 正文

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

[06-11 19:38:38]   来源:http://www.xxk123.com  网页设计   阅读:8618

导读: 在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聊天窗口中点击链接出现提示效果的方法-H

仿QQ聊天窗口中点击链接出现提示效果的方法,标签:网页设计教程,网页设计知识,http://www.xxk123.com

    在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">

[1] [2]  下一页


Tag:网页设计网页设计教程,网页设计知识电脑教学 - 网页设计

Copyright 学学看123 All Right Reserved.

1 2 3 4 5 6 7 8 9 10