Loading iframe URLs via events not working?

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Custom Loading Icons to Enhance Your Loading Screens
  • Hi,

    I've always wondered about this. I've never in my years of using Construct 3 been able to make iframes load URLs after runtime, through an event action.

    For instance, I currently have an action similar to this in my event sheet:

    On button press - Load URL "http://google.com"

    But on runtime, the debug window shows the iframe as having:

    iframe URL about:blank

    (about:blank is the default URL that the iframe object has in the properties)

    This is not specific to my project. I've simply never been able to make an iframe load any URL on runtime. iframes only seem to be able to load the URLs that they were assigned through the properties while editing the object in the editor.

    Is anyone else familiar with this, and does anyone know how to fix this?

  • You probably can get some more info about what didn’t work by looking at the browser console. Shift+ctrl+ i in chrome and edge.

    There are loads of limits and restrictions with web stuff. Generally i think iframes prefer urls with the same origin as your games url. If the url has a different origin then there may be a different set of rules and restrictions for that. Google could even block itself from loading from inside an iframe i’d imagine. It’s all likely very similar to the limit of loading images from different origins (CORS).

    You can refer to the mdn site for details or stackoverflow for some more specific solutions perhaps.

    In the case of Google supposedly this link would work based on someone on stackoverflow, but I haven’t tested.

    "https://www.google.com/webhp?igu=1"

  • You probably can get some more info about what didn’t work by looking at the browser console. Shift+ctrl+ i in chrome and edge.

    There are no console or network errors to speak of when this happens as far as I can see, and it also doesn't seem to matter what URL I'm trying to load or from which origin. There seems to be something about loading URLs on runtime that doesn't work, while loading the same URL as a property setting within the iframe object works fine.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Probably a bug then. Perhaps it’s not really used often enough to be noticed before.

  • "http://google.com" - won't load because it's HTTP

    and the HTTPS version won't load because as ROJOhound says it's a CORS issue.

    construct.net loads fine (using iframe -> "navigate to" action), so it's not a C3 issue.

    But you should be getting these errors in the console.

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