Now although most modern browser support document.querySelectorAll()
, you may run into problems with older versions of Internet Explorer. The obvious way of checking if the browser supports a function would be:
if(document.querySelectorAll){
//some random code
}
But from what I understand some browsers like (IE8) don't support certain properties, like 'body *
'. Is there a better way to check if document.querySelectorAll('body *')
will actually work?
test Browser support or not , without try-catch
or
thanx : http://htmlgoodies.com/beyond/javascript/using-javascripts-css3-selectors.html
Use typeof to check it:
document.querySelectorAll
will thrown on any unsupported selector so you can simply use atry-catch
block.