My website is https://www.example.com/write, I want to use this page as IFRAME in ionic 4 application, I am already embedded. But I want URL change event of IFRAME, while I am working inside iframe in my app. For example, inside IFRAME, I have "Publish" button, on that button, I am redirecting page, but I want that click event in my ionic 4 app, that user has clicked "Publish" button, or if I can get the new url, using that I can get user get back to the app.
Here is sample code:
<ion-header>
<ion-toolbar class="gradient-header font">
<ion-title style="background: transparent;" class="light-back small-text-header">Write Story</ion-title>
<ion-buttons slot="end"> </ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid fixed style="padding-right:0;">
<ion-row style="padding-right:0;">
<ion-col style="padding-right:0;">
<iframe [src]="urlSafe" style="width: 100%; height: 100vh;border:none;"></iframe>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
Here is TS file : write.page.ts
import { Component, OnInit } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { Observable } from "rxjs";
@Component({
selector: 'app-write',
templateUrl: './write.page.html',
styleUrls: ['./write.page.scss'],
})
export class WritePage implements OnInit {
urlSafe: SafeResourceUrl;
data:Observable<any>;
n_link:string = 'https://www.example.com/write';
constructor(public sanitizer: DomSanitizer) { }
ngOnInit() {
this.urlSafe= this.sanitizer.bypassSecurityTrustResourceUrl(this.n_link);
}
}