0

How i can access to IFrame DOM in angular 6 I can easily get iframe element - this.hostElement.nativeElement.querySelector('iframe').

But i don't know how i can get some element inside this iframe, and, for example, change style attributes or change something in DOM. This iframe is from outside, from another domain.

Akj
  • 7,038
  • 3
  • 28
  • 40
Yauheni Zuyeu
  • 11
  • 1
  • 5

1 Answers1

-1

iframe has it's own DOM tree (with own document and window elements) and you need to 'get' it's document to get inner elements.

To do so use .contentWindow

Eg.
this.hostElement.nativeElement.querySelector('iframe').contentWindow.document.querySelector()

Paulie
  • 164
  • 5