Archived

This topic is now archived and is closed to further replies.

java script question, using roll in, roll out,

This topic is 5148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im using javascript for some college work, and i need to use roll in , roll out, so when a mouse goes over the image it changes to something, and when it goes off the image it changes back to the orginal image. ive got the code that does this, theres one image in the example, and i need multiple images. SO i copied the roll in, roll out code and just added it to another line so it shows 2 images.
quote:
img src="teddy.gif" name="teddy" width="107" height="98" onMouseOver="setNewSrc()" onMouseOut="resetSrc()"/
the problem is the pictures no longer respond to my mouse moving over it or off it. what could it be?
<html>

<head>
	<title>Exercise 3:Using onMouseOver and onMouseOut</title>
	<style>
		h1 {color: #00ff00}
		h2 {color: green}
		p {color: rgb(0,0,255)}
	</style>
	<script type="text/javascript">
	<!--
	function resizeWindow()
	{
		top.resizeTo(450,550);
		return true;
	}

	if (document.images)
	{
		function setNewSrc()
		{
			document.teddy.src="spainBear.gif";
		}
		function resetSrc()
		{
			document.teddy.src="teddy.gif		}
	}


	// -->

	</script>
</head>

<body onload="resizeWindow()">
 	<h1>Using onMouseOver and onMouseOut </h1>
	<img src="teddy.gif" name="teddy" width="107" height="98" onMouseOver="setNewSrc()" onMouseOut="resetSrc()"/>
	
//stuff i made a copy of

<img src="teddy.gif" name="teddy" width="107" height="98" onMouseOver="setNewSrc()" onMouseOut="resetSrc()"/>
	

	
</body>
</html>

the site link thanks, [edited by - johnnyBravo on November 12, 2003 10:13:54 PM]

Share this post


Link to post
Share on other sites
now there''s two teddys. which one should it change? ERROR!

events create references to the tag that caused them. i forget what it all is, but you can get the document element from that and change that .src without ever knowing the name of the element itself

Share this post


Link to post
Share on other sites