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?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.