intendation. check window&document existence.