I've created this rollover menu that works just perfectly in Firefox, doesn't work at all in Chrome, and rolls over to the entirely wrong place in IE.
The JS isI placed this on the page at the default image:PHP Code:
<SCRIPT TYPE="text/javascript">
<!--
// copyright 1998 Idocs, Inc. http://www.idocs.com/tags/
// Distribute this script freely, but please keep this
// notice with the code.
// var image information object
var mloi=new Object();
// set the image for swapping
function setswap()
{
if (! document.images)return;
var imgInfo=new Object();
imgInfo.defaultImg = new Image();
imgInfo.defaultImg.src = document.images[arguments[0]].src;
imgInfo.opts = new Object();
for (var i=1; i < arguments.length; i=i+2)
{
imgInfo.opts[arguments[i]]=new Image();
imgInfo.opts[arguments[i]].src = arguments[i+1];
}
mloi[arguments[0]] = imgInfo;
}
// set up the link for swapping
function swap(link,imgName,optName)
{
if (! document.images)return;
if (! link.swapReady)
{
link.imgName = imgName;
link.onmouseout = swapBack;
link.swapReady = true;
}
document.images[imgName].src=mloi[imgName].opts[optName].src;
}
function swapBack()
{document.images[this.imgName].src=mloi[this.imgName].defaultImg.src}
//-->
</SCRIPT>
And then within the HTML, I have these links: (there are 8 but I only listed 2 as examples.)PHP Code:
<img src="images/mullan_house_670.jpg" width=670 height=500 alt="MLco" name="showservice">
<br />
<script type="text/javascript">
setswap("showservice",
'des', 'images/design_670.jpg',
'wal', 'images/walks_670.jpg',
'maint', 'images/maint_670.jpg',
'light', 'images/lighting_maple_670.jpg',
'hol', 'images/holiday_670.jpg',
'kitch', 'images/kitchen_670.jpg',
'spec', 'images/specialty_670.jpg',
'drain', 'images/drainage_670.jpg'
);
</script>
In IE, the rollover event takes place in the last thumbnail. I'm wondering if I have the setswap function in the wrong place?PHP Code:<div id="design">
<a href="design.html" onmouseover="swap(this,'showservice','des')"><img src="images/thumb_design.jpg" name="showservice" width="70" height="70"></a>
</div>
<div id="walks">
<a href="walks.html" onmouseover="swap(this,'showservice','wal')">
<img src="images/thumb_walks.jpg" name="showservice" width="70" height="70" ></a>
</div>
Please help! I have searched for an answer and stayed up almost all night trying to figure this out. I am new to JavaScript but trying VERY HARD to learn and not just copy scripts.


Reply With Quote
, here you are a quick solve:
Bookmarks