Solved

Image.src error on reload

Posted on 2004-09-22
4
277 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

708 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

14 Experts available now in Live!

Get 1:1 Help Now