• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Javascript Rollover Help

Superwormy

Golden Member
I need a javascript for a disjoint rollover ASAP. Can anyone help me?

All its gotta do, is when you mouseover one image, anotther image will change. Thanks!
 
I don't quite know what you mean by a "disjoint" rollover, but I think I get what you want. Here's some example JavaScript and HTML code that should show you how to achieve what you want:

---------------------------------------

<script language="JavaScript">
<!--

// You can remove the lines with two slashes at the start as they are only comments

// This part of the code loads the rollover images
if (document.images) {

image2_on = new Image();
image2_on.src = "image2_on.gif";

image2_off = new Image();
image2_off.src = "image2_off.gif";

}

// This function switches the images
// The parameters are passed in the form of 'image name', 'image src'
function changeImages() {
if (document.images) {
for (var y=0; y < changeImages.arguments.length; y+=2) {
document[changeImages.arguments[y]].src = eval(changeImages.arguments[y+1] + ".src");
}
}
}

//-->
</script>

<img src="image1.gif" onmouseover="changeImages('image2', 'image2_on')" onmouseout="changeImages('image2', 'image2_off')">

<img src="image2_off.gif" name="image2">

---------------------------------------

The JavaScript goes between the <head></head> tags of your page and the HTML code for the images obviously goes wherever in between your <body></body> tags (not necessarily together).

Hope that helps you - please post back if you need any more help 🙂

teknodude

[edit]
check out a demo of this code in action at http://www.gplenderleith.freeserve.co.uk/demos/twopartrollover.htm
[/edit]
 
Originally posted by: earthman
You can also do this with layers, changing the content of a div and have it reset on mouseout.

Err...yeah...but I don't think that will achieve what Superwormy wants.

teknodude
 
Back
Top