Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3406492
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:38:04+00:00 2026-05-18T05:38:04+00:00

I have some JavaScript code that dynamically injects an iframe in a given HTML

  • 0

I have some JavaScript code that dynamically injects an iframe in a given HTML page. Unfortunately, in Firefox, and only in Firefox, although the iframe is created from time to time the relevant URL isn’t loaded into it.

I know it wasn’t loaded because the relevant URL doesn’t appear in the Firebug Net tab, and when I inspect the iframe I don’t see any expected HTML code in there (when the iframe is on the same domain as the outlying page). I don’t see any JavaScript or network errors either.

Here’s a code snippet, I’ve checked all the relevant variables are correct:

    var iframe = document.createElement("iframe");
    iframe.width = options["w"];
    iframe.height = options["h"];
    iframe.scrolling = "no";
    iframe.marginWidth = 0;
    iframe.marginHeight = 0;
    iframe.frameBorder = 0;
    iframe.style.borderWidth = 0;

    if (node.childNodes.length > 0) 
        node.insertBefore(iframe, node.childNodes[0]);
    else 
        node.appendChild(iframe);

    iframe.contentWindow.location = iframeSrc + "?" + querystring;

Here’s an example URL that is set for the iframe (the issue also recreates when the URL points to an external server, had to omit the ‘http://’ at the beginning otherwise I couldn’t post the question):

127.0.0.1:8000/widget/iframe/index.html?style=slide-top-to-bottom&culture_code=en_us&c=26&sc=1324&title=Top%20News&caption=Top%20Stories&order=relevance&count=20&w=250&h=300&timestamp=true&scrollbar=false&theme=ui-lightness&className=8815455464592103&referrer=http%3A%2F%2F127.0.0.1%3A8000%2Fwidget%2Fbuilder%2Findex.html

Doing some research on the web, I found this unfixed Firefox bug which seems related to this issue:
https://bugzilla.mozilla.org/show_bug.cgi?id=279048

After reading the bug, I tried several solutions none of which solved the issue:

  • Setting iframe.src instead of iframe.contentWindow.location
  • Adding a random parameter to the querystring
  • Adding the ‘#’ symbol with a random number at the end of the URL
  • Giving the iframe a random name

Does anyone have a workaround for this annoying Firefox bug? Or is the issue I’m describing unrelated to the bug and has a different solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:38:05+00:00Added an answer on May 18, 2026 at 5:38 am

    Solved the issue, I was looking in the wrong place. The HTML file where this dynamic iframe was loaded had an empty iframe tag that was removed from the DOM, after which the dynamic iframe was injected instead.

    Apparently Firefox cached the last URL for this iframe, and loaded it immediately as the external page loaded. I know because I saw the relevant HTML file being loaded twice in the Firebug Net tab rather than once upon the injection.

    After I got rid of this empty iframe tag and relied only on the injected iframe, everything started to work well and the issue didn’t reproduce anymore. I guess Firefox didn’t like handling this scenario, some kind of bug maybe?

    Thanks anyway for helping me out, it gave me the inspiration for the right solution 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery/JavaScript code that I want to run only when there is
I have some code in a javascript file that needs to send queries back
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
I have some javascript that I'm trying to retool using jQuery to learn the
I have problem in some JavaScript that I am writing where the Switch statement
I have coded some JavaScript to perform an ajax call in an asp.net application.
Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can
I have to do some JavaScript in the future, so it is time to
I have some settings I need in a Javascript file -- servers to connect
I want to write some javascript and have it call into the DOM for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.