html超链接 鼠标效果,HTML超链接鼠标在图像上

你可以做到这一点使用JavaScript ..

这将创建一个跟随你的DIV或元素悬停鼠标一个正方形。

创建这里这些内容.js文件:

var WindowVisible = null;

function WindowShow() {

this.bind = function(obj,url,height,width) {

obj.url = url;

obj.mheight = height;

obj.mwidth = width;

obj.onmouseover = function(e) {

if (WindowVisible == null) {

if (!e) e = window.event;

var tmp = document.createElement("div");

tmp.style.position = 'absolute';

tmp.style.top = parseInt(e.clientY + 15) + 'px';

tmp.style.left = parseInt(e.clientX + 15) + 'px';

var iframe = document.createElement('iframe');

iframe.src = this.url;

iframe.style.border = '0px';

iframe.style.height = parseInt(this.mheight)+'px';

iframe.style.width = parseInt(this.mwidth)+'px';

iframe.style.position = 'absolute';

iframe.style.top = '0px';

iframe.style.left = '0px';

tmp.appendChild(iframe);

tmp.style.display = 'none';

WindowVisible = tmp;

document.body.appendChild(tmp);

tmp.style.height = parseInt(this.mheight) + 'px';

tmp.style.width = parseInt(this.mwidth) + 'px';

tmp.style.display = 'block';

}

}

obj.onmouseout = function() {

if (WindowVisible != null) {

document.body.removeChild(WindowVisible);

WindowVisible = null;

}

}

obj.onmousemove = function(e) {

if (!e) e = window.event;

WindowVisible.style.top = parseInt(e.clientY + 15) + 'px';

WindowVisible.style.left = parseInt(e.clientX + 15) + 'px';

}

}

}

然后在你的HTML执行以下操作:

包含的js文件

把你的网页:

var asd = new WindowShow();

asd.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);

这是在HTML的完全实现:

test page

div.block { width: 300px; height: 300px; background-color: red; }

iframe { border: 0px; padding: 0px; margin: 0px; }

var asd = new WindowShow();

asd.bind(document.getElementById('go1'),'IMAGE URL HERE!',400,480);

再见!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值