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 6335289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:49:38+00:00 2026-05-24T18:49:38+00:00

I am writing a code to add a div depending on a set of

  • 0

I am writing a code to add a div depending on a set of ‘object’ found in document on click of button.

When Document.getElementsByTagName(‘object’);
there is only one object, but it goes in to an infinite loop! giving me incremented value of swf.length incremented by one infinitely in an alert.
can you help whats wrong am i doing!

<script>
 function get2(){
    var swf = document.getElementsByTagName('object');
    for (j=0;j<swf.length ;j++ )
    {
        alert(swf.length);
        var objs = swf[j].getElementsByTagName('param');
        for(i=0;i<objs.length;i++){
            id = objs[i].getAttribute('name');
            if (id == 'src'){
                source = objs[i].getAttribute('value')
                dv = document.createElement('div');
                dv.setAttribute('id','myContent');
                dv.setAttribute('border','2');

               document.getElementsByTagName('body')[0].appendChild(dv);
               /* code to embed a new swf object in new Div*/

            }/*if*/
        }/*for*/
    }/*outer for*/
 }/*function*/

here is the HTML part:

<body>


<div id="old">
</br><h1> Hello </h1>

<object id="myId1" width="250" height="250" name="movie1" classid="clsid:d27cdb6e-ae6d-    11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"><param name="src" value="whitebird.swf">
</object>
<h1> welcome to flash</h1>

</div>
</br>
<input type="button"  onclick="get2()" value="Insert"/>
</body>
  • 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-24T18:49:39+00:00Added an answer on May 24, 2026 at 6:49 pm

    Put a breakpoint in your inner for loop and inspect the values of j, i, and getElementsByTagName(‘object’).length as well as swf[j].getElementsByTagName(‘param’).length after the first iteration and post the results. Try getting your length outside the loop (which is good practice anyway). Also use the var keyword in your loops:

    var objectLength = swf.length;
    for (var j = 0; j < objectLength; j++)
    {
         ...
    }
    

    You aren’t adding more object tag in your div and just omitted that code are you?

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

Sidebar

Related Questions

I am writing some code to add file attachments into an application I am
After writing code to populate textboxes from an object, such as: txtFirstName.Text = customer.FirstName;
I was writing code in eclipse when a compile error suggested I add exceptions.
I'm writing code that is part of an automation system. I wanted to add
Quick question. I was writing out some code and was curious if there is
I have been writing some code that detects add and removal of USB devices,
When writing code do you consciously program defensively to ensure high program quality and
While writing code in a file that would comprise of PHP, HTML, CSS &
While writing code, it is pretty common to request a page with an appended
When writing code in an Eclipse project, I'm usually quite messy and undisciplined in

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.