Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Image | Q655 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.