javascript - IE9 unable to get property 'remove' of undefined or null reference -



javascript - IE9 unable to get property 'remove' of undefined or null reference -

i working on site, need load big banner header. header has default styles, need remove if specific page has banner. these styles in class, removed server side if there banner present. works across browsers, except in ie9.

document.onreadystatechange = function () { // initialize app when document "ready" if (document.readystate == "complete") { var dom = {}; dom.$header = document.queryselector('.js-header'); dom.$banner = document.queryselector('.js-banner-image'); resizebanner(); } } function resizebanner(){ if(dom.$banner && dom.$banner !== null && dom.$banner !== undefined) { dom.$header.classlist.remove('has-no-banner'); } }

the browser halts when tries remove class, because "unable property 'remove' of undefined or null reference". however, variable defined , element exists in dom.

if go page doesn't have banner, function doesn't fire (this expected behaviour), logically it's not conditional that's messed up, finds dom.$banner fine, test i've tried giving element id, , declare right before method. did not solve problem.

the script file referenced in bottom of document defer async.

what doing wrong here?

the .classlist property not supported in ie9. utilize more traditional way of adding/removing classes shown here: adding , deleting objects in javascript

javascript internet-explorer-9

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -