Object doesn’t support property or method ‘querySelectorAll’

Object doesn’t support property or method ‘querySelectorAll’

If you user to find length of selected check box using querySelectorAll something similar as below and run code on IE could create throw Object doesn’t support property or method ‘querySelectorAll’ exception.

var len = [].slice.call(document.querySelectorAll("[name='checkBoxName']")).filter(function(e) { return e.checked; }).length;

 

or something like:

var titleCheckBox = document.querySelectorAll("");

To resolve this issue please follow below steps:

  • Please check that your page isn’t in Quirks mode or Compatibility mode. You can use the F12 dev tools to confirm this. Press F12 and look in the top-right corner of the resulting window. If you see “Compatibility” or “Quirks” in the mode description, then that should be the problem.
  • Quirks mode: this is usually triggered by a missing or broken Doctype. If this is the case, make sure your page starts with the following:

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

 

Once you add above code in your page that should resolve the issue if not please try below:

  • Compatibility mode (IE7 mode): This may be triggered if you’re viewing the page locally (ie running it on your local machine, eg for testing, or on your local network). In this case, you are being hit by an IE config setting that you should disable. Go to the Tools menu, and pick the Comaptibility View Settings option. Untick the compatibility options, and the page should start working.
  • Compat mode may also be triggered (or avoided) by an X-UA-Compatibility meta tag. If you’re having trouble with compatibility mode, this is a good way to avoid it: Add the following line to your code:

<meta http-equiv="X-UA-Compatible" content="IE=edge">

 

Leave a Reply

Your email address will not be published. Required fields are marked *