johnsankey
01-01-2012, 04:16 PM
I'm a total beginner at both CSS and Javascript. What I want to do is to swap things on mouseover, and keep the code as simple as possible both so I have a chance of understanding it and so it will work on as many browsers as possible.
I've got an image swap to work as I hoped using the method at http://acmeous.blogspot.com/2008/07/simplest-way-to-change-images-on-mouse.html, and am hoping to swap DIVs in the same way, with the initial DIV containing text and a thumbnail, and the replacement DIV a full size image.
I started with http://www.willmaster.com/library/features/mouseover_div_swap.php
In the following, mousing over should cause initDiv to disappear and imageDiv to appear; mousing out should cause imageDiv to disappear and initDiv to appear. Instead, I see imageDiv flickering over initDiv whenever the mouse is moved within the div.
What's the simplest way to correct my error?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style type="text/css">
.mybox { width:full; height:115px; border-color:black; border-style:solid; border-width:1px; padding:0px; }
</style>
<script type="text/javascript" language="JavaScript"><!--
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }
--></script>
<div id="imageDiv" class="mybox" style="display:none;">
large image here of same dimensions as DIV
</div>
<span onmouseover="HideDIV('initDiv');DisplayDIV('imageDiv')" onmouseout="HideDIV('imageDiv');DisplayDIV('initDiv')" style="cursor:pointer">
<div id="initDiv" class="mybox">
<table><tr><td>lots of text<td>thumbnail</table>
</div>
</span>
</html>
I've got an image swap to work as I hoped using the method at http://acmeous.blogspot.com/2008/07/simplest-way-to-change-images-on-mouse.html, and am hoping to swap DIVs in the same way, with the initial DIV containing text and a thumbnail, and the replacement DIV a full size image.
I started with http://www.willmaster.com/library/features/mouseover_div_swap.php
In the following, mousing over should cause initDiv to disappear and imageDiv to appear; mousing out should cause imageDiv to disappear and initDiv to appear. Instead, I see imageDiv flickering over initDiv whenever the mouse is moved within the div.
What's the simplest way to correct my error?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<style type="text/css">
.mybox { width:full; height:115px; border-color:black; border-style:solid; border-width:1px; padding:0px; }
</style>
<script type="text/javascript" language="JavaScript"><!--
function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }
--></script>
<div id="imageDiv" class="mybox" style="display:none;">
large image here of same dimensions as DIV
</div>
<span onmouseover="HideDIV('initDiv');DisplayDIV('imageDiv')" onmouseout="HideDIV('imageDiv');DisplayDIV('initDiv')" style="cursor:pointer">
<div id="initDiv" class="mybox">
<table><tr><td>lots of text<td>thumbnail</table>
</div>
</span>
</html>