exit-intent-popup icon indicating copy to clipboard operation
exit-intent-popup copied to clipboard

JS Error on every page

Open atchavoshihnia opened this issue 9 years ago • 8 comments

Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. at Object.addCSS (http://www.casamoda.com/media/exit-intent-popup/js/bioep.min.js:4:94)

atchavoshihnia avatar Jan 24 '17 13:01 atchavoshihnia

Could you provide a live URL where this error happens?

It could be due to a malformed <head> tag on the page, however the script should be handling this correctly regardless.

beeker1121 avatar Jan 26 '17 16:01 beeker1121

Yeah sure. You’ll get the exception on every page within our shop http://www.casamoda.com/

Here are some exceptions, caught through sentry:

· NotFoundErrormedia/exit-intent-popup/js/bioep in Object.window.bioEp.addCSS https://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/issues/208438145/ Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node. o vor 3 Stunden — 2 Tage old o javascripthttps://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/?query=logger%3Ajavascript ErrorNotFoundErrormedia/exit-intent-popup/js/bioep in window.bioEp.addCSS https://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/issues/208460508/ Node was not found o vor 3 Stunden — 2 Tage old o javascripthttps://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/?query=logger%3Ajavascript ErrorNotFoundErrormedia/exit-intent-popup/js/bioep in ? https://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/issues/208443893/ DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist. o vor 3 Stunden — 2 Tage old ErrorNotFoundErrormedia/exit-intent-popup/js/bioep in window.bioEp.addCSS https://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/issues/208461431/ Node was not found o vor 3 Stunden — 2 Tage old o javascripthttps://sentry.io/casamoda-heinrich-katt-gmbh-co/casamoda-b2c/?query=logger%3Ajavascript

atchavoshihnia avatar Jan 26 '17 18:01 atchavoshihnia

bioep_popup bioep_popup2

Hmm, it seems to be working for me without any errors. I've attached a couple of screenshots showing the popup and errors.

I have an idea for a fix but I'm unable to replicate the error, so it would be kind of a shot in the dark. The idea is to change how the addCSS function works, so it does not try looking for a currently existing <style> element within the <head> element, but rather just appends the CSS as the last child of the <head> element.

If your page or browser/plugins do something to change the <head> tag to where the bioep script can't refer to it, then that's probably the issue. The fix then would be to append the CSS to the top of the body, but this is not within standards.

I could possibly add an option to choose where to append the CSS, either to the head or body element.

beeker1121 avatar Jan 26 '17 18:01 beeker1121

Since Sentry is receiving the exception from all kinds of users on a second basis, the problem seems pretty imminent. Function wise everything works just fine. The problem is, AFAIK, just a cosmetic one…given the probably avoidable exception throwing of our users browsers. If you could just catch the exception that would be already fine I suppose.

The following two Exceptions might come in handy: https://sentry.io/share/issue/3131353638302e323039323737383032/ https://sentry.io/share/issue/3131353638302e323038343433383933/

Thanks for your quick efforts!

atchavoshihnia avatar Jan 26 '17 18:01 atchavoshihnia

Hi, this issue is occurring on our site too. You can reproduce by going to https://www.intrigu.com/blogs

Note that it only happens on this one page. If you could investigate that would be great!

TolganLight avatar Mar 28 '17 04:03 TolganLight

I'm also having this issue on one page and only page only. Was there a fix?

tone4407 avatar Aug 21 '17 18:08 tone4407

I'm also having this issue on one page. Doing A/B test with 2 landing pages. No issues on A, this error on B, and exit-intent won't work. The div just appears at the bottom of the page. Been racking by brain trying to solve this one. Perplexing.

Edit. Found my issue. It is because I had some style tags for page B that I want to override the standard css for page A. It was a lazy way to make some quick changes to page B, now I'll do it the proper way. :) The error makes sense given what it's trying to do at this line.

// Insert it before other existing style
    // elements so user CSS isn't overwritten
    document.head.insertBefore(style, document.getElementsByTagName("style")[0]);
  },

austinarchibald avatar Sep 23 '17 05:09 austinarchibald

This Error also prevents custom events (fe. to close on bg click, as described by maintainer on his blog, top section of comments) from functioning as expected

elhenro avatar Jun 04 '18 16:06 elhenro