IntelliJ Java IDE
The moose likes HTML, CSS and JavaScript and the fly likes Refreshing an embedded object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Refreshing an embedded object" Watch "Refreshing an embedded object" New topic
Author

Refreshing an embedded object

Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
I have a HTML window with a couple frames. In the second frame, I have an embed tag which looks like this:

From the other frame, I've written some JavaScript to change the src attribute of that embed tag. That code looks like this:

What I've found is that the src attribute changes (I put alerts on either side of the assignment operator and can see the change occur), but the embed object does not refresh to reflect the new image.
Is there a way I can get that object (or that frame) to refresh?
For now, I've gotten around it by rewriting the entire frame every time I want to refresh. It works, but it seems awfully wasteful.
Thanks,
Corey


SCJP Tipline, etc.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
why are you embeding the image istead of using the image tag? If you are just using it to display the image then I would not attack it that way.
TRhis is what I would do:

<form name="Pic">
<img src="blah1.gif" name="ThePic">
</form>
in the other frame use
parent.framename.document.Pic.ThePic.src="blah2.gif";
Eric
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by Eric Pascarello:
why are you embeding the image istead of using the image tag?

Because the image I need to display is a tiff, which IE does not display natively through an img tag.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
set the name in the object to id instead
<object id="ObjectID">
then
try using the following
parent.FrameName.document.getElementById('ObjectID').src="blah";
 
 
subject: Refreshing an embedded object
 
Threads others viewed
I am not able to display image
Frame Problem
Problem using html frames with struts and tiles
JSP and HTML Frames
How to change the src attribute of embed tag