How do I get the Window object from the Document object?

Viewed 81807

I can get window.document but how can I get document.window? I need to know how to do this in all browsers.

6 Answers

I opted to inject the DOCUMENT token from @angular/platform-browser:

import { DOCUMENT } from '@angular/platform-browser'

and then access the parent:

constructor(@Inject(DOCUMENT) private document: any) {
}

public ngOnInit() {
  // this.document.defaultView || this.document.parentWindow;
}
Related