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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:18:47+00:00 2026-05-23T01:18:47+00:00

Clarification: The parent frame is Page X, the child frame resides within page X.

  • 0

Clarification: The parent frame is Page X, the child frame resides within page X.
The issue is the slow behavior and never hitting the section of code that clears the interval.

I have a parent and chilframe. An object is created in the parent then I used setTimeout() in the childframe to call the parent object to add itself to an internal collection within the parent object.

The code doesn’t seem to behave as intended with really slow response from the browser. Any thoughts on the issue?

Parent frame

<script type="text/javascript">
       var Cert = new Parent();
    </script>

Child frame

<script  type="text/javascript">
        var c;
        var id = setInterval("Create()", 1000);

        function Create()
        {
            if (parent.Cert != null && parent.Cert != undefined)
            {
                c = new Child(parent.Cert, 1, null);
                clearInterval(id);
            }
        }
    </script>
  • 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-23T01:18:48+00:00Added an answer on May 23, 2026 at 1:18 am

    Don’t pass a string to setTimeout/Interval. Pass it a function reference instead!

    var id = setInterval(function () {
        Create();
    }, 1000);
    

    From the code you’ve given here, parent is window. Is this what you intend? There seems to be some relevant code missing here…

    As for the slowdown, perhaps the function interval is too short, or it is never being satisfied? There could also be an error in the constructor for the Child class, which would make it so the clearInterval line won’t ever be called. You could consider putting a limiter out there, or wrapping your instantiation in a try...catch block, or moving the clearInterval statement above the line where you’re creating your object.

    Or, do all of those things:

        var c = null;
        var id = setInterval(function () {
            Create();
        }, 1000);
    
        var itr = 0;
        function Create() {
            // if it has looped more than 20 times, forget it
            if (itr > 20) {
               /* show an error message? */
               clearInterval(id);
               return false;
            }
    
            if (parent.Cert != null && typeof parent.Cert != 'undefined') {
                // clear the interval first
                clearInterval(id);
                // safely create object
                try {
                    c = new Child(parent.Cert, 1, null);
                } catch (e) {
                   /* handle exception here */
                }
            } else {
                // incrementing the interval counter
                itr++;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
I need some clarification. I have a Reportwriter dll that uses Crystal Reports. It
I have the following DIV structure: <div id=parent> <div id=child></div> <div id=child2></div> </div> I
Why is my custom UIView not rendering within the UIView container of it's parent?
I've a medium chunk of code containing 5 classes that they're all inherited from
I am exploring parent process & child processes concept in UNIX. I wrote this
For clarification, here's the exact question in the about_regular_expressions.rb file that I'm having trouble
Is it possible to make a static object in a parent class that subclasses
My question is simple, is the next code safe? struct Parent { B* _a;
Clarification This is part of a script that checks if a user has changed

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.