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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:27:53+00:00 2026-06-02T02:27:53+00:00

I have a large javascript function init() that hides and shows a large number

  • 0

I have a large javascript function init() that hides and shows a large number of div’s. When the page is loaded the javascript function is triggered by the script below.

<script type="text/javascript">
$(document).ready(function() {
init();
});
</script>

Most of the time the javascript is triggered by the script below. However once in a while the script init() seems not to be triggered. Approximately 1 of 20 times the function init() seems not to be triggered. All the other 19 times the page and javascript is working fine without any errors. The circumstances when this error occurs seem to be no different from normally as this error occurs when Pressing F5 20 times.

I checked that init() seems to not being called at all because the first statement (alert(“function called”);) in init() wasn’t called. In the cases that the javascript was working fine I got the alert message and the page was loaded fine without any errors.

I tried different ways to trigger the javascript such as window.onload and putting at the end of the page this script:

<script type="text/javascript">init();</script>

All those different methods to trigger init() didn’t seem to make any difference.

This is the init() function:

function init(){
pauzereload__gl_var=1;
load2__gl_var=0;

//Hide bus options:
var boxbusnotshow = document.getElementById("boxDiv").getElementsByTagName("a");
boxbusnotshow[3].style.display="none";
boxbusnotshow[4].style.display="none";
boxbusnotshow[5].style.display="none";

document.getElementById("loadingdiv").style.display = "none";
document.getElementById("loadingdivdate").style.display = "none";
getvariables(); //Get variables generated by the php script, to get activetab

var a=1; b=1;
highlightboxinitiate(a,activetab__gl_var,load2__gl_var);
highlightlistinitiate(a,b);

pauzereload__gl_var=0;
}

This is the highlightboxinitiate function that is being called from the init() function:

function highlightboxinitiate(divnr,linenr,load2__gl_var) {

getvariables();

for (i = 1; i < 8; i++) {document.getElementById("nextnr" + i).style.display = "none";}
if(counttab__gl_var[linenr]>(9 + settab__gl_var[linenr]) && load2__gl_var==0){
document.getElementById("nextnr" + linenr).style.display = "block";}

for (i = 1; i < 8; i++) {document.getElementById("prevnr" + i).style.display = "none";}
if(settab__gl_var[linenr] >2 && load2__gl_var==0){
document.getElementById("prevnr" + linenr).style.display = "block";}

for (i = 1; i < 8; i++) {document.getElementById("pagenr" + i).style.display = "none";}
if(load2__gl_var==0 && counttab__gl_var[linenr]>9){
document.getElementById("pagenr" + linenr).style.display = "block";}


if(load2__gl_var==1){
for (i = 1; i < 8; i++) {document.getElementById("renextnr" + i).style.display = "none";}
if(counttab__gl_var[linenr]>(9 + settab__gl_var[linenr])){
document.getElementById("renextnr" + linenr).style.display = "block";}

for (i = 1; i < 8; i++) {document.getElementById("reprevnr" + i).style.display = "none";}
if(settab__gl_var[linenr] > 2){
document.getElementById("reprevnr" + linenr).style.display = "block";}

for (i = 1; i < 8; i++) {document.getElementById("repagenr" + i).style.display = "none";}
if(counttab__gl_var[linenr]>9){
document.getElementById("repagenr" + linenr).style.display = "block";}
}

var box = document.getElementById("boxDiv").getElementsByTagName("a");
current_tab__gl_var=linenr;
   for (i = 0; i < box.length; i++) {unselectboxinitiate(divnr,i);}

tabselnr = linenr-1;
if (tabselnr<=2){box[tabselnr].className="selected1";}
if (tabselnr>2 && tabselnr<=5){box[tabselnr].className="selected2";}
if (tabselnr==6){box[tabselnr].className="selected3";}


    for (j = 1; j < 10; j++) {
    for (i = 1; i < 8; i++) {
    document.getElementById("list"+j+"n"+i).style.display = "none";
    document.getElementById("it"+j+"n"+i).style.display = "none";}
    document.getElementById("list"+j+"n"+linenr).style.display = "block";
    document.getElementById("it"+1+"n"+linenr).style.display = "block";}

}

This is the highlightlistinitiate function that is being called from the init() function:

function highlightlistinitiate(divnr,linenr) {
   var box = document.getElementById("listmenu").getElementsByTagName("a");
current_list__gl_var=linenr;
   for (i = 0; i < box.length; i++) {
    box[i].className="unselected";}
    box[linenr-1].className="selected";
        for (j = 1; j < 10; j++) {
    for (i = 1; i < 8; i++) {
    document.getElementById("it"+j+"n"+i).style.display = "none";}}
    document.getElementById("it"+current_list__gl_var+"n"+current_tab__gl_var).style.display = "block";
    }

This is the getvariables function that is being called from the highlightboxinitiate function:

function getvariables(){
counttab__gl_var = new Array (7);
settab__gl_var = new Array (7);
counttab__gl_var [1] = 83; settab__gl_var [1] = 0; activetab__gl_var = 2; counttab__gl_var [2] = 111; settab__gl_var [2] = 0; activetab__gl_var = 2; counttab__gl_var [3] = 137; settab__gl_var [3] = 0; activetab__gl_var = 2; counttab__gl_var [4] = 1; settab__gl_var [4] = 0; activetab__gl_var = 2; counttab__gl_var [5] = 1; settab__gl_var [5] = 0; activetab__gl_var = 2; counttab__gl_var [6] = 1; settab__gl_var [6] = 0; activetab__gl_var = 2; counttab__gl_var [7] = 1; settab__gl_var [7] = 0; activetab__gl_var = 2; }

I have the impression that the functions are ok because when the page was not properly initiated the first statement in the init() function was not executed.

I checked that crossbrowser is not influencing this problem. This problem occurs in all browsers.

When the error occurs I don’t see any error messages in the firebug console.

I’ve been searching and debugging a lot so any help will be very welcome and appreciated!

  • 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-02T02:27:55+00:00Added an answer on June 2, 2026 at 2:27 am

    The problem was that somehow not all the content was loaded into the page, so the javascript crashed because it couldn’t find all the objects.

    The following statement at the end of the page helped resolve this issue:

    <?php
    print str_pad('',4096)."\n";
    ob_flush();
    flush();
    set_time_limit(45);
    ?>
    

    The above sends everything parsed until that statement to the browser.

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

Sidebar

Related Questions

I have a javascript rich page that is passing a large JSON formatted to
Problem: I have a page that has a large form, and in the middle
I have a large number of checkboxes on the page each in a separate
I have the following code: JS <script type=text/javascript> $(function(){ $('#fgotpwfield').hide(); $('#login_submit').click(function() { $('#form_result').fadeOut('fast'); $('#myccrxlogin
I have a large javascript which I didn't write but I need to use
I have large video files (~100GB) that are local on my machine. I have
Hey. I have this javascript file that I'm getting off the web and it
I have a document that loads some content into a div with JQuery's .load()
I've got a rather hideous and large javascript file that I've inherited from a
I have a trivial little game I wrote in javascript that creates a wave

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.