Skip to content

Comments

Fix iframe support#956

Merged
barryvdh merged 9 commits intomasterfrom
fix-iframe
Jan 20, 2026
Merged

Fix iframe support#956
barryvdh merged 9 commits intomasterfrom
fix-iframe

Conversation

@barryvdh
Copy link
Collaborator

No description provided.

@barryvdh barryvdh mentioned this pull request Jan 20, 2026
@erikn69
Copy link
Contributor

erikn69 commented Jan 20, 2026

I noticed that the variable name can be changed through the settings and I have created another alternative.

@barryvdh barryvdh mentioned this pull request Jan 20, 2026
@barryvdh
Copy link
Collaborator Author

I noticed that the variable name can be changed through the settings and I have created another alternative.

Yes I've changed the way I did this to use the global window.PhpDebugbar object instead of the variable name.

@barryvdh barryvdh changed the title Fix window name for iframe Fix iframe suppirt Jan 20, 2026
@barryvdh
Copy link
Collaborator Author

Althought there isn't really a need to change the var name, because it's in an anonymous scope anyways.

@barryvdh
Copy link
Collaborator Author

Hmm there can be some timing issues, it seems. Because it's not always directly loaded. Not sure if we can make sure to wait for the parent to load.

/** @var \DebugBar\JavascriptRenderer $debugbarRenderer */

$debugbarRenderer->setAssetHandlerUrl('../assets.php')
->setOpenHandlerUrl('../open.php');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid this the way I do it; wouldn't that be better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but I'm using Laravel herd and that renders /demo in the subfolder, so wouldn't work there.

@barryvdh barryvdh changed the title Fix iframe suppirt Fix iframe support Jan 20, 2026
@barryvdh
Copy link
Collaborator Author

Okay yeah we can just check the global window.top.PhpDebugbar variable, and only check the instance when we're actually adding data.

@barryvdh barryvdh merged commit 6a93ae1 into master Jan 20, 2026
@erikn69
Copy link
Contributor

erikn69 commented Jan 20, 2026

I tried your solution, the demo doesn't work 100%,
the AJAX call inside iframe2.php isn't being captured

My PR
image

This PR
image

@barryvdh
Copy link
Collaborator Author

Was that because of your fix in the debugbar or in the settimeout in the demo?

@barryvdh
Copy link
Collaborator Author

I tried your solution, the demo doesn't work 100%, the AJAX call inside iframe2.php isn't being captured

My PR image

This PR image

#959 fixes that, but it doesn't change anything in the code for the debugbar. It's a timing issue because the debugbars aren't initialized yet otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants