Error Using JavaScript’s this Keyword

Even though this is a reserved word in JavaScript, the following code fails…

with(parent){...this.window.event...} 

…because it can’t back out of parent.

The workaround is to assign the window object to a variable first:

o=window; with(parent){...o.event...}

That works, although it’s clumsy.

Author’s Note: This was fail-tested on the Microsoft Internet Explorer versions 6 and 7 popup object.
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: