Error: cannot set properties of null (setting ‘onclick’) /// but works in localhost (three.js)


This Content is from Stack Overflow. Question asked by yoons6

Button isn’t clicked in mobile and also github server.
It only works in my localhost…

I have cannot set properties of null (setting 'onclick') error on live server and github server(
However, it works in my localhost. No that error.
Also, hover event(turning color to white) is working…

I think something wrong in button click event code.

This is html code.

    <div id="overlay">
      <button id="startButton" type="button">HAPPY BIRTHDAY</button>
      <audio id="song" src=""></audio>


    <script src="public/bundle.js"></script>
    <script src=""></script>

This is js code.

if (WEBGL.isWebGLAvailable()) {
  const startButton = document.getElementById( 'startButton' );

  function init() {
    const overlay = document.getElementById( 'overlay' );

    setTimeout(function () {
    }, 0);

    setTimeout(function () {
    }, 1000);
} else {


Help me.. Please…


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?