Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouse over and mouse out issues

Status
Not open for further replies.

Jen53403

Programmer
Jul 17, 2006
22
I have an unordered list of links to different pages, and each list item has an "onmouseover" attribute that triggers a Javascript function mouseOver(prod). This function changes the src of the main image on the page to a different image file, depending on the value of prod. So the user can move his mouse over the list of items and view a picture of the item his mouse is hovering over. When the mouse is not hovering over any of the list items, the image src reverts to a default file. This is accomplished using an "onmouseout" attribute attached to the ul.

This all works the way it should, but I have one issue with it. There is a very small space between each list item that is not a "hotspot" and where the main image would switch back to the default. So the user moves his mouse over all the items, and the default image flashes briefly between each item. I hope this makes sense. How can I eliminate this annoying little problem? Here is the relevant code:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
	<script type="text/javascript">
	function mouseOver(prod)
	{
		document.display.src = "prod_imgs/" + prod + ".jpg";
	}
	function mouseOut()
	{
		document.display.src = "prod_imgs/all_products.jpg";
	}
	</script>
</head>
<body>
	<div id="product-tabs">
		<ul onmouseout="mouseOut()">
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('temp')">Temperature</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('level')">Level</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('pressure')">Pressure</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('flow')">Flow meters</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('sanitary')">Sanitary</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('controls')">Controls</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('valves')">Valves</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('pneumatics')">Pneumatics</a></li>
			<li><a href="[URL unfurl="true"]http://www.google.com"[/URL] onmouseover="mouseOver('heat_exchanger')">Heat exchangers</a></li>
		</ul>
	</div>
	<div id="product-images">
		<img src="prod_imgs/all_products.jpg" alt="product images" name="display">
	</div>
</body>
</html>
 
easiest way, if you don't have any styling in your anchor tags already, is to make them block.

Code:
<style type="text/css">
li a {
    display: block;
}
</style>

if you really need a javascript solution, i suppose you could use a timeOut to delay the switch...



*cLFlaVA
----------------------------
[tt]mr. pibb + red vines = crazy delicious![/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Change your CSS so that there is no margin space between each of the links.

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
I tried using display: block, but in IE, that put an extra line between the li's and spread them out too far.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top