David G
David G

Reputation: 96835

Why is DOMWindow not defined when the constructor of 'this' is DOMWindow

I'm trying to find DOMWindow but it keeps saying it's undefined. How do I get it?

(function() {
    alert(this.constructor); // function DOMWindow() { [native code] }
    alert(DOMWindow); // DOMWindow is undefiend
})();

What's wrong here??

Upvotes: 1

Views: 126

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270677

Perhaps what you want is alert(window) or alert(window.constructor)? DOMWindow is the constructor function which creates window.

(function() {
    alert(this.constructor); // function DOMWindow() { [native code] }
    alert(window); 
    // or...
    alert(window.constructor);
})();

// window shows:
// [Object DOMWindow]

// window.constructor shows:
// function DOMWindow() { [native code] }

Upvotes: 2

Related Questions