I am having an issue with Javascript. I\'m getting this error message:
Uncaught NotFoundError: Failed to execute \'insertBefore\' on \'Node\': The nod
Try using the parentNode:
originalDiv.parentNode.insertBefore(newVideo, originalDiv);
This will insert newVideo directly in front of the originalDiv.
The reason is that node.insertBefore(newNode, existingNode)
uses node
as a reference to the element that surrounds the existingNode
.
Ref: http://www.w3schools.com/jsref/met_node_insertbefore.asp
It's also what Google Analytics does: http://www.stevesouders.com/blog/2010/05/11/appendchild-vs-insertbefore/