Skip to content

Instantly share code, notes, and snippets.

Created May 18, 2012 09:49
  • Star 27 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save connrs/2724353 to your computer and use it in GitHub Desktop.
IE7 querySelectorAll polyfill
if (!document.querySelectorAll) {
document.querySelectorAll = function(selector) {
var doc = document,
head = doc.documentElement.firstChild,
styleTag = doc.createElement('STYLE');
doc.__qsaels = [];
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}";
window.scrollBy(0, 0);
return doc.__qsaels;
document.querySelectorAll||(document.querySelectorAll=function(a){var b=document,c=b.documentElement.firstChild,d=b.createElement("STYLE");return c.appendChild(d),b.__qsaels=[],d.styleSheet.cssText=a+"{x:expression(document.__qsaels.push(this))}",window.scrollBy(0,0),b.__qsaels});
Copy link

connrs commented Feb 26, 2020

I'm not massively surprised it doesn't work. This was pulled off StackOverflow 8 years ago and it worked for a limited set of scenarios that I needed when building software for clients who still used IE7. If you aren't having any luck with this then I'd recommend looking for a real alternative to this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment