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 - 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)****

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

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

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

****Below is code (iframe.html)****
   function hello() {
alert("Hello World!");
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.

In executeIframe

reference the iframe using an integer, instead of the page name, looks like something gets cached badly, change



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.