Solved

Image.src error on reload

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

728 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