Solved

Dynamic Images

Posted on 1998-11-02
2
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Assistance Implementing ShockWaveFlash Object in Excel VBA 3 21
alert on input text 2 41
links not working 2 34
Drag & Drop Error 5 31
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

732 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