Solved

Image.src error on reload

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

773 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