分享
 
 
 

一个优秀的超链接鼠标悬停提示CSS+JS

王朝html/css/js·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

超链接,一般的做法是给一个title属性,这样用户的鼠标悬停在超链接上的时候,它会显示title的内容。但是,你是否厌倦了千篇一律的鼠标悬停效果呢?

当然,也有这方面很炫的代码,但是才跨浏览器方面功夫还是不够,呵呵。我遇到一个不错的css,在IE和Firefox下浏览一样的效果。

下图是实际运行的效果:

代码如下:

/******************************************************

dw_viewport.js

version date Nov 2003

This code is from Dynamic Web Coding

at http://www.dyn-web.com/

Copyright 2003 by Sharon Paine

See Terms of Use at http://www.dyn-web.com/bus/terms.html

regarding conditions under which you may use this code.

This notice must be retained in the code as is!

*******************************************************/

var viewport = {

getWinWidth: function () {

this.width = 0;

if (window.innerWidth) this.width = window.innerWidth - 18;

else if (document.documentElement && document.documentElement.clientWidth)

this.width = document.documentElement.clientWidth;

else if (document.body && document.body.clientWidth)

this.width = document.body.clientWidth;

},

getWinHeight: function () {

this.height = 0;

if (window.innerHeight) this.height = window.innerHeight - 18;

else if (document.documentElement && document.documentElement.clientHeight)

this.height = document.documentElement.clientHeight;

else if (document.body && document.body.clientHeight)

this.height = document.body.clientHeight;

},

getScrollX: function () {

this.scrollX = 0;

if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset;

else if (document.documentElement && document.documentElement.scrollLeft)

this.scrollX = document.documentElement.scrollLeft;

else if (document.body && document.body.scrollLeft)

this.scrollX = document.body.scrollLeft;

else if (window.scrollX) this.scrollX = window.scrollX;

},

getScrollY: function () {

this.scrollY = 0;

if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset;

else if (document.documentElement && document.documentElement.scrollTop)

this.scrollY = document.documentElement.scrollTop;

else if (document.body && document.body.scrollTop)

this.scrollY = document.body.scrollTop;

else if (window.scrollY) this.scrollY = window.scrollY;

},

getAll: function () {

this.getWinWidth(); this.getWinHeight();

this.getScrollX(); this.getScrollY();

}

}

/****************************************************

dw_event.js (version date Feb 2004)

This code is from Dynamic Web Coding at http://www.dyn-web.com/

See Terms of Use at http://www.dyn-web.com/bus/terms.html

regarding conditions under which you may use this code.

This notice must be retained in the code as is!

*******************************************************/

var dw_event = {

add: function(obj, etype, fp, cap) {

cap = cap || false;

if (obj.addEventListener) obj.addEventListener(etype, fp, cap);

else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);

},

remove: function(obj, etype, fp, cap) {

cap = cap || false;

if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);

else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);

},

DOMit: function(e) {

e = e? e: window.event;

e.tgt = e.srcElement? e.srcElement: e.target;

if (!e.preventDefault) e.preventDefault = function () { return false; }

if (!e.stopPropagation) e.stopPropagation = function () { if (window.event) window.event.cancelBubble = true; }

return e;

}

}

/**************************************************

dw_tooltip.js requires: dw_event.js and dw_viewport.js

version date: March 14, 2005

(minor changes in position algorithm and timer mechanism)

This code is from Dynamic Web Coding at dyn-web.com

Copyright 2003-5 by Sharon Paine

See Terms of Use at www.dyn-web.com/bus/terms.html

regarding conditions under which you may use this code.

This notice must be retained in the code as is!

*****************************************************/

var Tooltip = {

followMouse: true,

offX: 8,

offY: 12,

tipID: "tipDiv",

showDelay: 100,

hideDelay: 200,

ready:false, timer:null, tip:null,

init: function() {

if ( document.createElement && document.body && typeof document.body.appendChild != "undefined" ) {

if ( !document.getElementById(this.tipID) ) {

var el = document.createElement("DIV");

el.id = this.tipID; document.body.appendChild(el);

}

this.ready = true;

}

},

show: function(e, msg) {

if (this.timer) { clearTimeout(this.timer); this.timer = 0; }

this.tip = document.getElementById( this.tipID );

if (this.followMouse) // set up mousemove

dw_event.add( document, "mousemove", this.trackMouse, true );

this.writeTip(""); // for mac ie

this.writeTip(msg);

viewport.getAll();

this.positionTip(e);

this.timer = setTimeout("Tooltip.toggleVis('" + this.tipID + "', 'visible')", this.showDelay);

},

&n

[1] [2] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有