Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q655 How can I change the image and href property of another link when the mouse moves over another image?

You are here: irt.org | FAQ | JavaScript | Image | Q655 [ previous next ]

You can access the links array to alter the href property of another link:

<a href="default.htm"><img src="image1.gif" name="myImage" width="400" height="400" border="0"></a>

<script language="JavaScript"><!--
var lastvalue = 'default.htm';

function over(imageName,src,href) {
    var j, i;
    if (document.images) {
        for (var i=0;i<document.links.length;i++)
            if((document.links[i].href.length - lastvalue.length) == document.links[i].href.indexOf(lastvalue))
                j = i;
        document.links[j].href = lastvalue = href;
        document.images.imageName.src = src;
    }
}

function out() {
}

//--></script>

<p>

<a href="#" onMouseOver="over('myImage','image1.gif','http://www.irt.org/')" onMouseOut="out()"><img src="apicture.gif" width="100" height="100" border="0"></A>

Feedback on 'Q655 How can I change the image and href property of another link when the mouse moves over another image?'

©2018 Martin Webb