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

  • SEARCH
  • Home
  • 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 9117721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:57:48+00:00 2026-06-17T04:57:48+00:00

While rendering iframes , I use the code: ifrm = document.createElement(IFRAME); ifrm.style.width = 100%;

  • 0

While rendering iframes, I use the code:

ifrm = document.createElement("IFRAME");
ifrm.style.width = "100%";
ifrm.style.height = 600+"px";
function makeFrame() {
document.body.appendChild(ifrm);
}

However, this keeps appending iframes below the existing one, each time I call the function makeFrame(). So, if I call makeFrame() (say thrice), then I get three iframes one below the previous. How to prevent this and replace the existing one instead of appending to the last one?

  • 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-06-17T04:57:49+00:00Added an answer on June 17, 2026 at 4:57 am

    The simplest answer:

    If you want to change your code as little as possible, and you’re certain that you’ll only have exactly one iframe on the page at any given time

    function makeFrame() {
    oldiframe = document.getElementsByTagName("IFRAME")[0] 
    // getElementsByTagName will return an array (a list). 
    // Adding [0] will return the first (and, under our assumptions, only) element
    ifrm = document.createElement("IFRAME");
    ifrm.style.width = "100%";
    ifrm.style.height = 600+"px";
    document.body.replaceChild(ifrm, oldiframe);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do we need to do double buffering in BlackBerry while rendering our paint code
I have the following code in extjs and while rendering it is giving me
I want to test if my 'style.css' is linked to my page while rendering
Un Expected result while rendering @Html.ActionLink in the browser. Below are the code i
While rendering the view page, based on some condition in the controller action I
Most popular browsers, while rendering an image, they display it line-by-line top-to-bottom as it
I am using IE8 in compatibility view and while this does produce acceptable rendering,
While debugging and keep pressing F5, if the source code does not exist, eclipse
I am getting crazy while rendering a simple line chart with dojo toolkit. Everything
I get: TemplateSyntaxError at /blog/post/test Caught NameError while rendering: global name 'forms' is not

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.