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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:57:10+00:00 2026-06-11T00:57:10+00:00

Why site http://xn--wiadomesny-37b.pl/test/ throws Uncaught TypeError: Cannot set property ‘innerHTML’ of null ? HTML

  • 0

Why site http://xn--wiadomesny-37b.pl/test/ throws Uncaught TypeError: Cannot set property 'innerHTML' of null?

HTML (http://xn--wiadomesny-37b.pl/test/):

<div class="castle_array" id="2x1" name="2x1"></div>
<div class="castle_array" id="3x1" name="3x1"></div>
<div class="castle_array" id="4x1" name="4x1"></div>
...

JavaScript (http://xn--wiadomesny-37b.pl/test/B_modeWindow.js):

for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {
  document.getElementById(x+"x"+y).addEventListener("click",B_modeWindow('1',this.id));
}}

When I alter

("click",B_modeWindow('1',this.id)

to

("click",B_modeWindow('1','string')

it works like a charm – why?

  • 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-11T00:57:12+00:00Added an answer on June 11, 2026 at 12:57 am

    There are two fundamental issues with your code.

    First, when you do addEventListener("click", B_modeWindow('1', this.id));, you’re not assigning the B_modewindow callback to the click event handler, you are actually executing the function.

    Secondly, in that context this does not refer to the clicked element, it refers to the Window object, thus this.id gives you undefined, use event.target.id instead:

    To fix it, use the following instead:

    var el = document.getElementById(x+"x"+y);
    el.addEventListener("click", function (event) {
      B_modeWindow('1', event.target.id);
    });
    

    Here’s a simplified DEMO.

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

Sidebar

Related Questions

For example I have site http://localhost/site In IIS I set that 404 error causes
I recently deployed a site http://boardlite.com . One of the tester websites http://www.gidnetwork.com/tools/gzip-test.php suggests
On my site ( http://test.tamarawobben.nl ) I use an accordion menu. When I choose
On this site http://www.bostonteaclub.com I want the default language to be Chinese. I set
Test site: http://wfwgm.stage.philosophydesign.com/ I have included: <script src=http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js></script> to give :before support in IE6
Heres the site: http://designobvio.us/portfolio/body.html I've tried css3, % base. Cannot seem to get this
I have a site http://test.printavo.com that renders terribly in IE8 but fine in IE7
Copied from the site http://github.com/notahat/machinist/ Machinist makes it easy to create test data within
the site: http://shawn.sc2broadcast.net/test/ the code: <?php $homepage = file_get_contents('http://www.macsiam.com/sites.php'); preg_match_all('%\'http://([^./]+).[^.]+\.[a-z]{2,4}\'%i', $homepage, $domains, PREG_PATTERN_ORDER); //
In my site: http://www.indiacustomercare.com which Drupal 6 and I've set default format as Full

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.