evercookie icon indicating copy to clipboard operation
evercookie copied to clipboard

document.body.appendChild throws error

Open truongsinh opened this issue 12 years ago • 4 comments

There are many document.body.appendChilds, but only the one at line 600 (#evercookie_silverlight) throws error

Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist. evercookie.js:600
evercookie_silverlight evercookie.js:600
_evercookie evercookie.js:163
get evercookie.js:142
getC example.html:19
(anonymous function) example.html:15

truongsinh avatar Nov 20 '13 11:11 truongsinh

This bug still exists - Chrome does not take kindly to passing raw html into document.body.appendChild - its looking for a proper dom element. However the code for this section has a note that that the original developer tried to do it with a dom object but IE wasn't a fan..

I think a solution might be to substitute

document.body.innerHTML += html;

But I haven't tried it on other browsers yet..

sblackstone avatar Jan 15 '14 16:01 sblackstone

hello, what about document.createDocumentFragment, insert div in it, div.innerHTML = html and insert fragment in document? any problems with it? if no one tested, ill test and send pull request to you

wwwsevolod avatar Nov 18 '14 15:11 wwwsevolod

@sblackstone Why not perform a browser check and use both variants?

anubisthejackle avatar Mar 10 '15 17:03 anubisthejackle

It depends on a number of other commits, but I have a fix for this here: https://github.com/rbrenton/evercookie/commit/bb29d4251d98dda5af8c4bbae0476966d5863bf5

rbrenton avatar Apr 30 '15 18:04 rbrenton