Choose src of iframe in separate scene

Hi guys, I’m trying to do the following:

I have 2 scenes. In scene 1 there are two buttons. In scene 2 there is one html widget.
I would now like to choose the src of the html-widget depending on which of the two buttons hase been clicked. I’ve tried a lot, but can’t do the trick… Can you guys help me? Thank you so much!

First don’t use the HTML widget if not needed and rather just stick in a iFrame into an container giving you more control.

Store a value in hypeDocument when clicking.

Either way you can just give the HTML widget or the preferred iFrame a class and then fetch it on scene load in the next scene. There you fetch the node with querySelector and you set the src attributes using setAttribute based on the value you stored in hypeDocument.

I’ll add a example in a minute.

1 Like

Here you go:
LoadFrameBasedOnVar.hype.zip (21,1 KB)

2 Likes

Hi,

Just curious… why don’t you use two Html widgets or better two iframes?
If I am correct it is just the same price. You could also use symbols with custom behaviour triggered by your buttons. That could be more flexible with more than two choices.
Have a great day.

That is true. You can do it in pur Hype. I tend to quickly come up with a coding solution. Only thing with two widgets … make sure they don’t render at the same time. If you don’t each site loads and draws resources. Maybe set the iframe code with an animated inner HTML property (record animation and use little pen on rectangle, paste iframe code) OR at least use display to hide the other (not opacity) OR use two scenes each with one HTML widget and symbols for the rest to avoid redundancy.

1 Like

Hi Max,

Great, that’s absolutely what I was looking for. Thx a lot. :+1: :+1:

@Galeace: The reason is exactly the one, Max has already explained. I am trying to load the same Hype-Content in all Scenes of my Hype-document with different “Dashboards”, depending on the user’s choice in Scene 1. Therefore, only one of the Dashboards is relevant to the user, loading all the others would just use unnecessary resources.

Again, thank you vermy much @MaxZieb!

2 Likes