0

I need to put a loader every time my iframe navigate for another url. I think it may be possible, with a logic like:

onLoad(Iframe: ElementRef) {
  this.Hide();
}

onNavigate(Iframe: ElementRef) { // this event does not exist
  this.show();
}

Do anyone has a idea of how to make it?

bahman parsamanesh
  • 2,194
  • 3
  • 13
  • 31
fba_pereira
  • 188
  • 2
  • 10

1 Answers1

1

Here's a similar thread

There're no navigation events on iframes, you can only get initial load on src property change. So if there is a SPA running in iframe, you will need to retreive it manually:

I would suggest you to use ngAfterViewCheck and retreive location like this

this.iframeLocation = iframeRef.nativeElement.contentWindow.location.href;

Main problem: browser will not allow you to get location if iframe is cross-origin.