Solved

Dynamic Images

Posted on 1998-11-02
2
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now