I’ve looked for a solution to this problem, and while it seems like something that others have come across in other situations I cannot find a solution as it pertains to the problem occurring in HYPE builds.
In my project I am changing the content of an iFrame using a javascript function (iframeElm.setAttribute (‘src’, theurl); ). This works perfectly fine on all platforms EXCEPT iOS devices. I can even recreate the issue if I simply change the user-agent in Safari on my Mac to any iOS (iPad, iPod touch, iPhone) version of Safari.
It isn’t that the content isn’t being displayed - it’s not loading: I have a script which is run by the content of the iFrame when it loads (which also works perfectly on desktop browsers) but it doesn’t run on iOS - because, I’m assuming, the content isn’t being loaded at all. Further, I’ve tested it by adding default content to the HTML widget itself, and THAT content appears but doesn’t change when the function is called.
Is this a know issue? Are there common workarounds?
I absolutely appreciate you taking the time to reply, but I’m sorry, I’m not sure what it is that you’re trying to say.
I can see, after examining the element (the HTML widget) via safari’s web inspector using both the default user-agent and an iOS user-agent that the frame appears to be structured differently - however I am unsure as to what change to make to get the frame to load on both desktop and mobile.
The content being loaded into the frame is an external page (on the same domain - but NOT included in the hype document itself).
Off-Topic as it's not regarding the iOS but the suggestion: I don't understand the global variable approach? Isn't it the same as: <button type="button" onclick="document.querySelector('#HTMLWidget iframe').setAttribute('src', 'rect.html');">Click Me!</button>
An ID always has to be unique on a page. Thats why I only use classes if you want truly local targeting inside the Hype Document DOM-Subtree scope. Specially if you start reusing symbols across scenes/layouts ID's are the worst and Hype actually renames them internally to avoid non unique ID's. That is also the reason Hype has the getter wrapper called hypeDocument.getElementById … as it first checks in a lookup if an ID has been renamed by Hype that you are requesting.
Getting back to @elroy… do you see any errors in the console log with remote debugging? It would probably be useful if you could post a zip of your .hype document, or at least the code that you’re using to get the iFrameElm, assuming it is from a HTML Widget.
Thank you for replying Jonathan. I’ve managed to solve the issue after falling down a rabbit hole inspired by the post that Hans linked to. I’m using an embedded iframe in a rectangle now and it renders correctly on both desktop and mobile.
Thank you everyone for the help - once again, this community has been an amazing asset to Hype.