Iframe reloads after show keyboard


#1

I’m using iframe with dynamic link.

[Updated to make more clear]
I created a page with an iframe. The url that the iframe will render has some input fields. When I click on this input field to type something, it shows the keyboard. When the keyboard appears it reloads the iframe’s content. So I can do nothing, because whenever I show the keyboard the iframe is reloaded.

my view:

<ion-content no-padding>
  <iframe [src]="urlTransform()"></iframe>
</ion-content>

my method in controller:

urlTransform() {
   return this.sanitizer.bypassSecurityTrustResourceUrl(this.url_base + this.url_params);
}

#3

I created a page with an iframe. The url that the iframe will render has some input fields. When I click on this input field to type something, it shows the keyboard. When the keyboard appears it reloads the iframe’s content. So I can do nothing, because whenever I show the keyboard the iframe is reloaded.


#4

I had a similar issue and my solution was to set [src] of iframe to a variable instead of function call. I set the variable in the constructor of the page. My guess is that it calls the function multiple times (maybe at ui updates) and each time it gets a new ResourceUrl and reloads the iframe.

In my case i added (load) event and it started constantly reloading the iframe.


#5

If you’re doing this:

<iframe [src]="urlTransform()"></iframe>

You’re iFrame-url is going to be continuously sanitized I suppose. Please safe the sanitized URL to a variable as @ales_rozman suggested. w


#6

Found any solution for the issue? I have similar issue.