Execute function inside iframe - FireFox problem

Posted on 2006-04-22
Last Modified: 2008-02-01
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!");
Question by:alexshop
    1 Comment
    LVL 22

    Accepted Solution

    In executeIframe

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



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
    Several part series to implement Internet Explorer 11 Enterprise Mode
    This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
    Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

    758 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

    9 Experts available now in Live!

    Get 1:1 Help Now