Execute function inside iframe - FireFox problem

I have 2 files: index.html and iframe.html

index.html - has 3 links.
Click "create iframe" - dynamically creates iframe
Click "execute iframe" - executes function inside iframe ("Hello World")
Click "close iframe" - closes iframe

Problem in FireFox 1.5.0.2 - if I will repeat these steps again - will be error: "window.frames.iframe1.hello is not a function"

How to solve this problem?
-------------------------------------------
Most interesting:
I can click many times (in series) "create iframe" and after "execute iframe" - and it works!!!


****Below is code (index.html)****

<script>
   function createIframe() {
      document.getElementById('div').innerHTML='<iframe id="iframe1_id" name="iframe1" src="iframe.html" width="100" height="100"></iframe>';
   }
   function executeIframe() {
      //iframe1.hello();
      window.frames["iframe1"].hello();
   }
   function closeIframe() {
      document.getElementById('div').innerHTML='';
   }
</script>

<a href="#" onclick="createIframe();">create iframe</a>
<br>
<a href="#" onclick="executeIframe();">execute iframe</a>
<br>
<a href="#" onclick="closeIframe();">close iframe</a>

<div id="div"></div>




****Below is code (iframe.html)****
<script>
   function hello() {
alert("Hello World!");
   }
</script>
alexshopAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RedKelvinCommented:
In executeIframe

reference the iframe using an integer, instead of the page name, looks like something gets cached badly, change
window.frames["iframe1"].hello();

to
frames[0].hello();

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.