开发者

Activating a link on rollover?

Is it possible whit a simple script to activate a link just by a roll开发者_StackOverflow社区over without click?


You can do this:

<a onmouseover="window.location = this.href" href="http://google.com">test</a>

But use it wisely. No one will be expecting it.

May I ask why you're trying to do this?


I suppose by activate you mean follow. This may well work on your tag

onmouseover="window.location=event.target.href"

It's possible some browsers will block the attempt to do that though.


Using some unobtrusive javascript it can be achieved fairly easily.

var link = document.getElementById("link");
link.onmouseover = function(){
    window.location.href = this.href;
};

Simple jsfiddle example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜