You are here:

DHTML/onMouseOver Link

Advertisement


Question
Hey, I'm designing a website and haven't really used Javascript a lot. Anyway,
what I've been trying to figure out (unsuccessfully...) is how/if it's possible to
activate a link when the mouse hover above it. I felt Javarscript would be the way
to go but I keep finding only images changing and how to customize the style of
a link...

I would be really happy if I could get some help (or if you know it is not
possible...)

//Robin

Answer
Hi Robin,

Try this:

<!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=iso-8859-1" />
<title></title>
</head>

<body>
<a href="#" onmouseover="location.href='http://google.com'">Hover</a>
</body>
</html>

DHTML

All Answers


Answers by Expert:


Ask Experts

Volunteer


Andrew Hoffman

Expertise

Ask me about JavaScript, CSS, HTML5/XHTML, or PHP. Chances are I'll be able to help you. I know the economy is in the tank, but if you like my answer, please consider donating a few bucks. It's like tipping your barista, if your barista served fresh code instead of coffee.

Experience

I started doing this when boy bands were still cool.

Education/Credentials
I read a lot of nerdy books to get here.

©2012 About.com, a part of The New York Times Company. All rights reserved.