I am currently working on an Angular application that involves a specific process:
Users follow a flow and end up on one of the partial pages.
From this partial page, I trigger a button to fetch an ID from a cross domain using a service call (no CORS issue).
With this ID, I append it to the URL of the cross domain like
This modified URL is then loaded in a child component inside an iframe.
The cross domain's page within the iframe contains 'Save' and 'Cancel' buttons.
Upon clicking either of these buttons, the application navigates back.
However, there is an ISSUE: When users click the 'Chrome browser's back button' after successful navigation, the application reloads.
This causes the entire flow of the application to restart, forcing customers to go through the flow again. Even though the data is updated upon return to the previous partial page, it creates a poor user experience.
Currently, I suspect that the use of DomSanitizer might be causing this strange behavior in Chrome while other browsers work fine.
Here is a snippet of the code used to load the cross domain's URL in the iframe:
constructor(private sanitizer: DomSanitizer) { }
ngOnInit() {
this.targetUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.sourceUrl);
}
Angular Template:
<iframe #crossDomainIframe [src]="targetUrl" (load)="onPageLoad()">
</iframe>
In the onPageLoad()
function, I simply handle the logic of returning the response to the parent component.
onPageLoad () {
this.callbackResponse.emit(returnUrl);
}
My question is: Is there a way to resolve this issue?
Alternatively, is there a different method for executing the cross domain request in the iframe?