Solved

Image.src error on reload

Posted on 2004-09-22
4
283 Views
Last Modified: 2010-05-18
Hi,

I am using frames and I am dynamically loading an image to a remote frame like this:-

---
parent.topFrame.titlePic.src='images/titleHome.gif'
---

This works fine on IE6 until the document is reloaded, then I get this error

---
parent.topFrame.titlePic is null or not an object.
---

In FireFox the image is not even swapped at all, regardless of whether the page is reloaded or  loading for the first time.


There is obviously something I am not doing right for both browsers.

Please show me the light!

!k*


0
Comment
Question by:khalamuntu
  • 2
4 Comments
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 50 total points
ID: 12121317
Hi khalamuntu,

I'm not sure if this will fix your frame reloading problem, but I'm pressed for time right now, so can't think too long, but I think for Firefox, try

parent.frames['topFrame'].document.images['titlePic'].src

Regards,
Zyloch
0
 
LVL 1

Author Comment

by:khalamuntu
ID: 12121372
Zyloch,

You were right, it worked for FireFox, but I still have the IE problem.

Thanks a million, though!


!k*
0
 
LVL 14

Accepted Solution

by:
tomaugerdotcom earned 50 total points
ID: 12122917
Just a question for you. The code that calls

parent.topFrame.titlePic.src='images/titleHome.gif'


when is it being called? If it's being called BEFORE the body is loaded, it would be natural that you would get this error (because the frame might not have loaded yet, or the titlePic image tag may not have been loaded etc). A quick fix to try would be to ensure that the code is called from an onLoad event handler within your body tag, like this:

<body onload="parent.topFrame.titlePic.src='images/titleHome.gif';">

For best results, this should be the body tag for the topFrame frame (to make sure that it's loaded before you try changing the img source).

Hope this helps!
Tom Auger | d3
0
 
LVL 1

Author Comment

by:khalamuntu
ID: 12127695
Of course, you are right!

Thanks to both of you.  I have increased the points so that you can share.


Later

!k*
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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