Solved

Dynamic Images

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need HTML output in powershell line by line 3 36
ASP get fieds value 2 21
CSS for Popup in ASP.NET 4 16
aria difference 2 14
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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 …

749 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