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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:30:52+00:00 2026-06-07T18:30:52+00:00

So the question is, why doesn’t this append the div’s on load? I’m scratching

  • 0

So the question is, why doesn’t this append the div’s on load? I’m scratching my head on this one. No errors… Just not loading.

<head>
    <script type="text/javascript">
        function load() {
            var divTag0 = document.createElement("div");
            divTag0.className = "newsBlock";
            divTag0.innerHTML = " Try this..";
            document.getElementById("newsLeft").appendChild(divTag0);

            var divTag1 = document.createElement("div");
            divTag1.className = "newsBlock";
            divTag1.innerHTML = " Blah..";
            document.getElementById("newsRight").appendChild(divTag1);

            var divTag2 = document.createElement("div");
            divTag2.className = "newsBlock";
            divTag2.innerHTML = " And this ..";
            document.getElementById("newsLeft").appendChild(divTag2);    
        }
    </script> 
</head>
<body>
    <p> Something filler </p>
    <div id="newsLeft">  
    </div>
    <div id="newsRight">     
    </div>
    <script type="text/javascript">
        window.onload="load()";
    </script>
</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-06-07T18:30:53+00:00Added an answer on June 7, 2026 at 6:30 pm

    If azhrei’s answer doesn’t work, the only thing I could think of would be that calling onload after it has loaded might not trigger, you can change this from your example by simply calling load();

    I tested it here

    Hope this helps

    EDIT:

    I believe azhrei has the right of it, it’s not so much that the onload isn’t triggering, it’s that there’s a syntax problem with your onload call.

    But this code can also be improved in terms of better style (more readable/ easier to comprehend) by removing the second JS call.

    In the header if you write:

    window.onload = function() { 
        //everything inside your load() function goes here
    } 
    

    It works just as well. It also removes a lot of the fluff that was just kind of there. I hope that helps.

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

Sidebar

Related Questions

I've checked through other questions and surprisingly this question doesn't seem to have been
I apologize in advance, if this question doesn't make sense. I'm a newbie. I
This post asks this question but doesn't really give an answer, so I thought
My question is this: Doesn't storing the salt as plaintext defeat the purpose of
I am very sorry if my question doesn't make sense as this is my
Sorry if this question doesn't make any sense. I'm currently in the midst of
First of all, I am sorry if this question doesn't belong to SO since
If the question doesn't seem very clear, it should be after this explanation !
I'm not a programmer so I apologize if my question doesn't make a lot
This question doesn't relate only to MouseEvent.CLICK event type but to all event types

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.