Home > DeveloperSection > Forums > Result of getElementById is null using javascript?
Chintoo Semi

Total Post:135

Posted on    August-19-2013 12:42 AM

 JavaScript JavaScript 

 1 Reply(s)
 985  View(s)
Rate this:
Hi Mindstick!

Down vote favorite

Just struggling with a Javascript class being used as a method for some cometishian code, how do I have a constructor for this code? The following code is invalid:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">   



        <link rel="Stylesheet" href="gStyle.css" />           

        <script type="text/javascript" language="javascript">   

            // Gantt chart object

            function ganttChart(gContainerID) {   

                this.isDebugMode = true;

                this.gContainer = document.getElementById(gContainerID);   

                if (this.isDebugMode) {

                    this.gContainer.innerHTML += "<div id=\"gDebug\">5,5 | 5.1</div>";



            var myChart = new ganttChart("chart1");                 





    <div id="chart1" class="gContainer"></div>   



thanks in advance

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-19-2013 8:35 AM


<script type="text/javascript">

var prevOnload = window.onload || function () {};

window.onload = function () {


// do your stuff here



Also, untill all images are fully loaded onload will not trigger, consider using jquery & $(document).ready or similar.

Don't want to miss updates? Please click the below button!

Follow MindStick