Anwill
Anwill

Reputation: 80

cloneNode() issue with Chrome/IE

I am having a problem. The following javascript works in Firefox, but is returning nothing is IE and Chrome (both latest versions)

var document_copy = document.cloneNode(true);
console.log(document_copy);

I am trying to clone the entire html document.

Am I doing something completely wrong?

Update: @CBroe came up with a work around using

document.documentElement.cloneNode(true);

Upvotes: 2

Views: 1059

Answers (2)

C3roe
C3roe

Reputation: 96407

I am trying to clone the entire html document.

Clone the html node instead – document.documentElement.cloneNode(true)

Upvotes: 2

Gabriele Petrioli
Gabriele Petrioli

Reputation: 196217

IE 10 works fine for me


For chrome it is not implemented yet (since it was implementation dependent, they chose not to support it).

See http://code.google.com/p/chromium/issues/detail?id=258146

Upvotes: 2

Related Questions