-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
<iframe on:load> does not trigger in all browsers #6967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The same code is being sent to all browsers, so I suspect the Firefox vs Chrome difference is a race condition, depending on whether the event has already fired by the time the handler is attached. Similarly, I suspect what's happening in SvelteKit is that the event handler isn't being attached until hydration, by which time the server-side rendered iframe has already loaded. If you want to run code regardless of whether the iframe has already loaded by the time the event handler is attached, I would suggest writing an action that checks whether the iframe has already loaded, and if it has, then immediately call the callback - and if it hasn't, then attach a |
thanks for the response! I'll try The reason that I'd consider it a Svelte(Kit) bug is that the vanilla |
Wanted to see if there was an update for this issue? Looking at iframes with SvelteKit and thi seems it could be a blocker for a project my team and I are are working on. |
Any update on this? |
Commenting as I ran into the same issue, used the workaround from @gi4no's commit. I'm curious if Svelte 5's switch to use |
Closing in favor of #11046 |
Describe the bug
iframes should trigger the onload event when they are finished loading, however in at least some browsers, an event handler for that event fails to trigger.
I have tested the following configurations:
The results were the same using
npm run dev
andnpm run start
/npm run preview
, and also in the Svelte REPL.I'm holding back on also reporting in the SvelteKit repo, as I was able to reproduce this using Svelte only in at least one case - let me know if I should create an issue there too.
Reproduction
Create a new Svelte(Kit) project (or skip this and paste the file contents below into a REPL):
Replace the contents of
src/App.svelte
/src/routes/index.svelte
with the following:Run using
npm run dev
or do a full build; open the site in a browser. Not all browsers show "iframe loaded" in the console.Logs
No response
System Info
REPL:
running Svelte compiler version 3.44.2
Severity
annoyance
The text was updated successfully, but these errors were encountered: