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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:03:03+00:00 2026-05-28T00:03:03+00:00

How to ensure that a Javascript function is finished before moving on to the

  • 0

How to ensure that a Javascript function is finished before moving on to the next line in the HTML code.

For eg : I am having a Javascript code in main() and calling tht as shown below. Before this finish off, the next line of HTML code like loading a JPEG is showing up in the webbrowser.
Is there any way I could ensure the main() call is executed completely.

<script language="JavaScript" type="text/javascript"> main();</script>

As some of you guessed correctly,There is an asynchroous call within the main() which uses a XMLHTTPRequest() to get some of the values I need to form the webpage. The function main is a s below

function main()
{
    var requestor = new net.Requestor("admin/getparam.cgi?mainvideostream&codectype", CurrentHandler);
}

and net.Requestor=function(url,onload,onerror,method,params,contentType)
within this thers is and XMLHTTPRequest(…)

And the Currenthandler is another function which deals with the response from the requset.

 function CurrentHandler()
 {  
    settings = this.req.responseText.split("\n");      
    for(var j=0; j<settings.length-1; j++)  
    {
       var currentST= settings[j].split("=");    
       name = currentST[0];
       value = currentST[1];
       switch(name)    
       {
         case "mainvideostream":  cur_camid = value; break;
          case "codectype": stream = value; break;
        }    
     }   
    mainSection();
  }

So I have to find out the stream variable before loading the page.

  • 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-28T00:03:03+00:00Added an answer on May 28, 2026 at 12:03 am

    The short answer is no, there is no (safe, standards compliant) way to stop the page from loading while your script runs.

    Typically, this is worked-around in one of two ways:

    1. Hide the elements on the page that you don’t want to appear to be loaded by setting their CSS display property to none. Add a command at the end of your script to reset the display property on those elements.

    2. Move the elements you do not want to initially load into a separate HTML file. At the end of your script execution, make an AJAX call back to the server to get that second file and load it into the appropriate point within your main file.

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

Sidebar

Related Questions

I have written some JavaScript and jQuery code that accepts only numeric input in
What can I do to this piece of code to ensure that it can
I am validating a zip code using Javascript that is generated server-side, and injected
I have the following JavaScript code: $('a.button').click(function(){ if (condition == 'true'){ function1(someVariable); function2(someOtherVariable); }
I have a javascript function that I would like to execute after every asynchronous
How do you ensure that the project will be build with good design decisions
I need to ensure that any number of websites and services haven't bitten the
How do you properly ensure that a user isnt tampering with querystring values or
How would you ensure that only one user is logged in per account at
I would like to ensure that I only subscribe once in a particular class

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.