I have quite a strange problem. This is happening inside a Cordova (hybrid HTML) app, but only on iOS.
I have my HTML page with some content already there, and that's ok. In a second moment, I'm retrieving some HTML from a remote page and I insert this HTML inside my main HTML page. If there's an iFrame with an SRC attribute specified, the system immediately opens that SRC inside safari/a specific app, but I just want to insert the content as a normal iFrame!
Example. If I retrieve this HTML:
<iframe src="https://www.youtube.com/watch?v=dQw4w9WgXcQ">
and let's say that I save this HTML element inside a variable foo. As soon as i do:
document.getElementById("XXX").appendChild(foo);
iOS immediately opens the youtube app. No user interaction, no triggers, nothing. Just by inserting the iFrame in the page. The same happens with any other SRC specified.
I tried to replace the "src" attribute with a fake one, like "data-src", insert the iFrame in the page and in a second moment put back the original SRC. As soon as I do that, the same stuff happens.
Do you have any idea on what is causing this and how to implement a workaround? On Android everything's fine.
P.S.: I'm using wkwebview, if that matters.
from iOS: inserting iFrame with SRC inside the page immediately opens the url in Safari
No comments:
Post a Comment