Home Forums NewsExo Pro [Bug Report] The JS timer should be only started when top header date enabled

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #40767
    mosser
    Participant

    In my site, I disabled the whole top header option. The JS timer throw error every 100ms in all pages, because the element with ID “newsexo-time” does not render.

    Error message:
    custom.js?ver=6.7:45
    Uncaught TypeError: Cannot set properties of null (setting ‘innerHTML’)

    File:
    \newsexo-pro\assets\js\custom.js (#line 45)

    Code:

    var myVar = setInterval(function() {
    myTimer();
    }, 100);

    function myTimer() {
    var d = new Date();
    document.getElementById(“newsexo-time”).innerHTML = d.toLocaleTimeString();
    }

    #40772
    themearile
    Keymaster

    Hi Mosser

    Please enable the site header on your site so we check the error and provide you better solution.

    Thanks

    #40773
    themearile
    Keymaster

    Hi Mosser

    Please enable the site header on your site so we check the error and provide you better solution.

    Thanks

    #40774
    mosser
    Participant

    Un commented the setInterval code snippet, you can now check the error log in my site.
    https://www.langsong.site/104448.html

    #40778
    themearile
    Keymaster

    Hi Mosser

    Ok please provide your site admin login details on our below email ID so we can fix your issue.

    themearile@gmail.com

    Thanks

    #40784
    mosser
    Participant

    Hi,

    thanks for your update.
    I think no need to further debug. In the next theme version, you just need to add a null check for html element newsexo-time in file assets/js/custom.js as below:

    
    		if(jQuery('#newsexo-time').length >0 ){
    		 var myVar = setInterval(function() {
    			myTimer();
    		  }, 100);
    		}  
    
    #40785
    themearile
    Keymaster

    Great, Thanks

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.