Solved

Dynamic Images

Posted on 1998-11-02
2
178 Views
Last Modified: 2010-04-09
I'm trying to create dhtml code which when I roll over certain words, 3 images in a different frame change.

Please help.

Antony
0
Comment
Question by:antony061897
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
rafistern earned 100 total points
ID: 1839352
This will work in IE4 and NS4:

<layer onmouseover="parent.otherFrame.document.images[0].src='new_url.gif'" onmouseout="parent.otherFrame.document.images[0].src='old_url.gif'">
<span onmouseover="parent.otherFrame.document.images[0].src='new_url.gif'" onmouseout="parent.otherFrame.document.images[0].src='old_url.gif'">
The words
</span>
</layer>

The layer tag is for NS4, the span for IE4.

You could write all this with a javascript:

<script language=javascript1.2>
if(navigator.appName="Netscape")
  tagname="span"
else
  tagname="layer"

document.write("<"+tagname+" onmouseover='parent.otherFrame.document.images[0].src=\"new_url.gif\"' onmouseout='parent.otherFrame.document.images[0].src=\"old_url.gif\"'>");
document.write("The words");
document.write("</"+tagname+">");

</script>

0
 
LVL 4

Expert Comment

by:rafistern
ID: 1839353
Here is aslightly neater javascript version taking into account all 3 images:

<script language=javascript1.2>
function changeSrc(imgName,srcURL){
  eval("parent.otherFrame.document."+imgName+".src='"+srcURL+"'");
}


if(navigator.appName="Netscape")
  tagname="span"
else
  tagname="layer"

document.write("<"+tagname+" onmouseover='changeSrc(\"image1\",\"new_src1.gif\");changeSrc(\"image2\",\"new_src2.gif\");changeSrc(\"image3\",\"new_src3.gif\");' onmouseout='changeSrc(\"image1\",\"old_src1.gif\");changeSrc(\"image2\",\"old_src2.gif\");changeSrc(\"image3\",\"old_src3.gif\");'>");
document.write("The words");
document.write("</"+tagname+">");

</script>

where 'image1' etc are names given to images in the other frame and 'new_src1.gif' etc are urls of image files.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS Logo Problem. 2 20
Converting dates in JavaScript 2 34
Save ms data to server side. 19 43
Select case on click 3 15
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question