解决方案 »
- document.getElementsByTagName添加JS调用后不成功
- 谁用过swfupload?进来下
- google map div 大小
- 这个方法如何调用 急~~~
- 怎么样利用javascript检查客户端是否已经安装了某些程序?如迅雷!
- 以模式窗口的方式打开新的窗口,顶者有分,不够再加
- form里有N个SELECT,在获得了SELECT的总个数以后,怎样取其中的一个?
- 急!急!急!急问!如何获得当前浏览器窗口的高度?
- 一个通过点击链接来指定iframe的src的问题!
- 后台表单提交后,刷新前台数据,这个问题怎么解决!
- 用javascript如何获得某个表格中的图片ID
- 关于JS动态传递参数的问题~
<a id='tip1' href="http://mootools.net" title="mootools homepage" class="thisisatooltip">我的悬停很炫</a>
<script>
var myTips = new Tips('.thisisatooltip');
$('tip1').store('tip:title', '<h2 style="color:red">标题</h2>');
$('tip1').store('tip:text', '<div>这是我的正文</div>');
</script>可以模拟,先给你个能用的例子,我懒的写,你自己看吧
<html>
<head>
<meta content="MSHTML 6.00.2800.1586" name="GENERATOR"> <script>
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
} var $ = function(id) {
return document.getElementById(id);
}; var mouseTip = Class.create(); ///*
mouseTip.prototype = {
initialize: function() {
var mao = this;
mao.randomId = ((new Date().valueOf()) * Math.random() + '').replace(/./g, '');
}, randomId: null, object: null, //指定div跟随的object content: null, //指定div中的内容 width: '100px', height: '30px', getElementpos: function() {
var mao = this; var o = mao.object
if (o) {
var t = o.offsetTop;
var l = o.offsetLeft;
var w = o.offsetWidth;
var h = o.offsetHeight;
while (o = o.offsetParent) {
t += o.offsetTop;
l += o.offsetLeft;
}
t += h;
return { top: t, left: l, width: w, height: h };
}
return null;
}, show: function() {
var mao = this;
var o = mao.object;
var t = mao.getElementpos().top, l = mao.getElementpos().left, w = mao.getElementpos().width, h = mao.getElementpos().height; var parent = document.createElement('div'); //主层
var ifr = document.createElement('iframe'); //用来覆盖窗体元素的iframe
var div = document.createElement('div'); //用来装载提示内容的层 div.id = 'div' + mao.randomId;
with (div.style) {
position = 'absolute';
width = mao.width;
height = mao.height;
top = '0px';
left = '0px';
zIndex = '10000';
padding = '5px';
overflowX = "hidden";
overflowY = "auto";
};
div.innerHTML = mao.content; ifr.id = 'ifr' + mao.randomId;
ifr.scrolling = 'no';
with (ifr.style) {
position = "absolute";
width = mao.width;
height = mao.height;
top = "0px";
left = "0px";
border = "none";
zIndex = "-1";
} parent.id = 'parent' + mao.randomId;
with (parent.style) {
position = "absolute";
left = l;
top = t;
width = mao.width;
height = mao.height;
padding = "0px";
border = "none";
zIndex = "1";
}
parent.appendChild(ifr);
parent.appendChild(div); document.body.appendChild(parent);
}, hide: function() {
var mao = this;
var o = $('parent' + mao.randomId);
if (o) {
document.body.removeChild(o);
}
}
}
//*/ var mao = new mouseTip();
mao.content = "<span style='color:red;'>链接</span>";
show = function(object) {
mao.object = object;
mao.show();
};
hide = function(object) {
mao.object = object;
mao.hide();
};
</script></head>
<body>
<input id="btnMouseOver" onmouseout="hide(this);" onmouseover="show(this);" type="button"
value="把鼠标移过来" />
<a onmouseout="hide(this);" onmouseover="show(this);">把鼠标移过来</a>
</body>
</html>想起来有藏了这么个东西,随便看看……
我记的我看过个代码,标签里没有onmouseover,
有个自定义属性titleContent,该属性值包含标签,
也有title属性,title属性为空。
鼠标悬浮时一样能显示出titleContent的内容,并能解析标签。