How do I load url on iframe?

  • hi in my app i have two layouts,

    in the first layout i have differents butons, if i click on buton one it load the layout 2 where the iframe is placed.

    i did this but nothing is working, when user click on buton 1, the global number var is set to 1.

    if compared values URL_VAR1=1 iframe set url to "http://www.lesoir.be/" and then go to layout 2

    in the layout 2, compare value if URL_VAR1=1, iframe load URL_VAR1.

    but its not working i want the iframe to load differents urls per butons ( one url per buton in layout 1)

    i get a loop with this error:

    Access Denied

    You don't have permission to access "http://www.lesoir.be/" on this server.

    Reference #18.25535d68.1512479426.a11065c

    and the Reference #18.25535d68.1512479426.a11065c is changing in loop and i cant access the url

    this is my menu butons at he moment i only use buton 1 (top)

    https://image.ibb.co/dA2Heb/menus.jpg

    can someone help?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Note that some sites won't open in iFrames. Others will detect the iFrame and refresh out of it. So. I'd suggest you check the sites you want to open in the iframe outside of your construct app, before trying to solve the problem on construct. A simples way to do that is by accesing the iframe TryIt! tool at w3schools (https://www.w3schools.com/tags/tryit.as ... tml_iframe), changing the url there and hitting "Run". If it doesn't open there, it wo'nt open on your construct app. For instance, I just checked "http://www.lesoir.be/" and it doesn't open in iframes...

    Hope this helps. Cheers!

  • well this is what i have at the moment

    if i add the url in the left settings of the iframe websites are loaded

    if i leave the iframe settings without a default url

    and try to load urls from the EVENTS, its NOT WORKING !!!

    i really need help for solving this issue !!!

  • Hi imothep85!

    Well... That doesn't make any sense. I checked the DH.be site and it opens on both situations, if you put it as default or when you click a button, the other one Le Soir, doesn't open in any of those situations. So, I can only assume that someting at Le Soir is keeping you from opening it inside an iFrame.

    https://www.dropbox.com/s/0ayn1szj5nzc8 ... .capx?dl=1

    Check this example. I have a button for LeSoir and I'm trying to open it by default. None of those work. All other sites, including DH.be work fine. Note, also, that TED site will blow the iFrame and open itself out of the construct window and in the main browser window.

    Cheers.

  • thanks im goign to see whats wrong with my events

  • My bet is that the problem is with some sites, not your events, but... Maybe both things are contributing to the problem. i can't say without checking your capx. Good luck!

  • here its my capx

    can you look at it?

    i cant click on my urls buttons and then open the iframe layout

    http://www.filedropper.com/allmediasv01

    thanks

  • Hey imothep85!

    Here's an adjusted capx. I added a loader, so the iFrame only shows after its content is fully loaded.

    https://www.dropbox.com/s/cb0axyo685ddv ... .capx?dl=1

    Also, I checked the Le Soir site and it has, indeed, a http header called X-Frame-Options set to "sameorigin", which keeps it from being loaded in a frame that is not on the same site.

    Note: do not add events to the layAssets layout. It's a eventless layout that has the purpose of storing stuff that will be created dynamically, since Construct 2 needs at least one instance to exist so it can load an object. Think of it as an asset repository.

    Hope this helps. Cheers!

  • Thanks brunopalermo

  • imothep85 I did not read all the messages but I think brunopalermo already helped you, but in any case, this plugin is not mine.

    But it looks like it's a simple error in your code. You are always asking to go to the site, so it will never load. You can resolve by simply placing a trigger in the sub-event.

    Cheers.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)