avoid error on internet explorer

internet explorer doesn't support the 'contains'
method on the document object.
solution: verify if root(element) has parent and is not
the document itself