Solved

Image.src error on reload

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
alert before form submission 6 32
Having problem getting this to work 2 21
Sorting a string 1 17
Get the number of current month days 2 0
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

862 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

23 Experts available now in Live!

Get 1:1 Help Now