Title: Console Error: Cannot set property &#8216;onclick&#8217;
Last modified: August 24, 2021

---

# Console Error: Cannot set property ‘onclick’

 *  Resolved [digdug5](https://wordpress.org/support/users/digdug5/)
 * (@digdug5)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/)
 * jquery-migrate.min.js?ver=3.3.2:2 JQMIGRATE: Migrate is installed, version 3.3.2
   
   jquery.min.js?ver=3.6.0:2 jQuery.Deferred exception: Cannot set property ‘onclick’
   of null TypeError: Cannot set property ‘onclick’ of null at HTMLDocument.<anonymous
   > ([https://www.000000000000000.com/wp-content/plugins/simple-banner/simple-banner.js?ver=2.10.5:56:79](https://www.000000000000000.com/wp-content/plugins/simple-banner/simple-banner.js?ver=2.10.5:56:79))
   at e ([https://www.0000000000000.com/wp-includes/js/jquery/jquery.min.js?ver=3.6.0:2:30038](https://www.0000000000000.com/wp-includes/js/jquery/jquery.min.js?ver=3.6.0:2:30038))
   at t ([https://www.00000000000000.com/wp-includes/js/jquery/jquery.min.js?ver=3.6.0:2:30340](https://www.00000000000000.com/wp-includes/js/jquery/jquery.min.js?ver=3.6.0:2:30340))
   undefined S.Deferred.exceptionHook @ jquery.min.js?ver=3.6.0:2 t @ jquery.min.
   js?ver=3.6.0:2 setTimeout (async) (anonymous) @ jquery.min.js?ver=3.6.0:2 c @
   jquery.min.js?ver=3.6.0:2 fireWith @ jquery.min.js?ver=3.6.0:2 fire @ jquery.
   min.js?ver=3.6.0:2 c @ jquery.min.js?ver=3.6.0:2 fireWith @ jquery.min.js?ver
   =3.6.0:2 ready @ jquery.min.js?ver=3.6.0:2 B @ jquery.min.js?ver=3.6.0:2 jquery.
   min.js?ver=3.6.0:2 Uncaught TypeError: Cannot set property ‘onclick’ of null 
   at HTMLDocument.<anonymous> (simple-banner.js?ver=2.10.5:56) at e (jquery.min.
   js?ver=3.6.0:2) at t (jquery.min.js?ver=3.6.0:2) (anonymous) @ simple-banner.
   js?ver=2.10.5:56 e @ jquery.min.js?ver=3.6.0:2 t @ jquery.min.js?ver=3.6.0:2 
   setTimeout (async) S.readyException @ jquery.min.js?ver=3.6.0:2 (anonymous) @
   jquery.min.js?ver=3.6.0:2 e @ jquery.min.js?ver=3.6.0:2 t @ jquery.min.js?ver
   =3.6.0:2 setTimeout (async) (anonymous) @ jquery.min.js?ver=3.6.0:2 c @ jquery.
   min.js?ver=3.6.0:2 fireWith @ jquery.min.js?ver=3.6.0:2 fire @ jquery.min.js?
   ver=3.6.0:2 c @ jquery.min.js?ver=3.6.0:2 fireWith @ jquery.min.js?ver=3.6.0:
   2 t @ jquery.min.js?ver=3.6.0:2 setTimeout (async) (anonymous) @ jquery.min.js?
   ver=3.6.0:2 c @ jquery.min.js?ver=3.6.0:2 fireWith @ jquery.min.js?ver=3.6.0:
   2 fire @ jquery.min.js?ver=3.6.0:2 c @ jquery.min.js?ver=3.6.0:2 fireWith @ jquery.
   min.js?ver=3.6.0:2 ready @ jquery.min.js?ver=3.6.0:2 B @ jquery.min.js?ver=3.6.0:
   2 Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into a 
   document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened. Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into
   a document from an asynchronously-loaded external script unless it is explicitly
   opened.

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * (@rpetersen29)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14800610)
 * Hi [@digdug5](https://wordpress.org/support/users/digdug5/)
    I’m not sure exactly
   what your code is doing, but you’ll need to wait for the banner to load on the
   DOM. You may be able to fix this by enabling the `wp_body_open` feature if your
   theme uses that wordpress hook. Otherwise the Banner loads via a script so you’ll
   need to add a settimeout to your function that calls if the element is not found
   on screen.
 *  Thread Starter [digdug5](https://wordpress.org/support/users/digdug5/)
 * (@digdug5)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14800656)
 * Thanks the only way I can get rid of the onclick error is to disable the close
   button option.
 *  Plugin Author [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * (@rpetersen29)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14800839)
 * Can you describe what your onclick action is doing?
 *  Thread Starter [digdug5](https://wordpress.org/support/users/digdug5/)
 * (@digdug5)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14803682)
 * Its the onclick event below thats causing the “Cannot set property ‘onclick’ 
   of null at HTMLDocument.”
 * if (simpleBannerVisible) {
    var sbCookie = “simplebannerclosed”; if (simpleBannerScriptParams.
   close_button_enabled){ if (getCookie(sbCookie) === “true”) { closeBanner(); }
   else { var expiration = parseInt(simpleBannerScriptParams.close_button_expiration)
   || 30; document.getElementById(“simple-banner-close-button”).onclick = function(){
   closeBanner(); setCookie(sbCookie, “true”, expiration); }; }
 *  Plugin Author [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * (@rpetersen29)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14804012)
 * Oh interesting. Javascript runs synchronously so that shouldn’t be happening.
   Does it only happen when your banner text is blank?
 *  Thread Starter [digdug5](https://wordpress.org/support/users/digdug5/)
 * (@digdug5)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14805228)
 * Yeah it seems like it may be related to the text being blank
 *  Plugin Author [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * (@rpetersen29)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14805635)
 * Okay, so it’s not a huge issue considering the banner won’t show if there’s no
   text. That error is simply due to the fact that there’s no element to attach 
   the onclick action to. And since there’s no banner shown then that’s fine. Obviously
   I don’t want to just be throwing a bunch of needless errors in the console so
   I’ll put out a fix soon. But in the meantime there’s nothing to worry about.
 *  [capegreg](https://wordpress.org/support/users/capegreg/)
 * (@capegreg)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14828412)
 * Also getting this same error. We were not showing a banner but still get the 
   error. We will disable the plugin until the fix is out. Thanks.
 * [https://www.manateepao.com/wp-content/plugins/simple-banner/simple-banner.js?ver=2.10.5](https://www.manateepao.com/wp-content/plugins/simple-banner/simple-banner.js?ver=2.10.5)
 * Uncaught TypeError: Cannot set property ‘onclick’ of null
    at HTMLDocument.<anonymous
   > (simple-banner.js?ver=2.10.5:56) at e (jquery.min.js?ver=3.6.0:2) at t (jquery.
   min.js?ver=3.6.0:2)
 *  Plugin Author [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * (@rpetersen29)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14836506)
 * [@capegreg](https://wordpress.org/support/users/capegreg/) [@digdug5](https://wordpress.org/support/users/digdug5/)
   Issue has been fixed in v2.10.6

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Console Error: Cannot set property ‘onclick’’ is closed to new replies.

 * ![](https://ps.w.org/simple-banner/assets/icon-256x256.png?rev=1198700)
 * [Simple Banner - Easily add multiple Banners/Bars/Notifications/Announcements to the top or bottom of your website](https://wordpress.org/plugins/simple-banner/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-banner/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-banner/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-banner/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-banner/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-banner/reviews/)

 * 9 replies
 * 3 participants
 * Last reply from: [rpetersen29](https://wordpress.org/support/users/rpetersen29/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/console-error-cannot-set-property-onclick/#post-14836506)
 * Status: resolved