-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Bug: iframe src
attribute set incorrectly in jsx
#25196
Comments
iFrames are chaotic evil in react |
@Noah670 99.9% of the time I would assume I am doing something wrong and that the React developers would call my issue a mis-use rather than a bug, but I think my MWE is very compelling. I doubt many people would see the MWE and expect it to succeed/fail depending on those curly braces. |
Created this Stackblitz documenting several attempted solution paths referenced here, here, and here. |
I just ran your code and it works as intended, I think you have a problem with word breaks, in the screenshots you have a break at I tested it via And I'm not a React Maintainer :) |
@FrameMuse thank you for this response! I'm not sure what I'm missing, please help me out:
To clarify, I wrote I don't claim that every iframe will fail to render with a JSX-style |
@zachsiegel-capsida I clearly see that the attribute |
Did you tested it in a "local environment" (I mean server that is running locally on your computer) or only on Stackblitz? |
And also in your example with iframe code you misput <iframe
src="https://capsida.sharepoint.com/sites/sitename/_layouts/15/Doc.aspx?sourcedoc={xxxxxx}&action=embedview"
width="476px"
height="288px"
frameBorder="0">
</iframe> It should be <iframe
src="https://capsida.sharepoint.com/sites/sitename/_layouts/15/Doc.aspx?sourcedoc={xxxxxx}&"
width="476px"
height="288px"
frameBorder="0"
action="embedview">
</iframe> |
after seeing the link and what you are trying to do the link or website you are trying to access has x-frame same-origin enable it means that you can't use it in iframes. definition:you have to check for HTTP response header X-Frame-Option of those sites. if its value is "DENY or SAMEORIGIN", then you can not load those website in the iframes. DENY = No one can load the website in iframe. Even the same domain page wont be able to load. |
As I wrote above, there is a problem with |
not it is not the case |
I had the error in console too, but when I put the attribute it disappreared and you're saying this is not the case, how's that? |
This has nothing to do with whether the iframe As I have mentioned, regardless of whether changing other |
As I have mentioned, I understand that there are many reasons why an |
Yes, I experienced this issue in a local React environment (serving on |
@zachsiegel-capsida |
@devjs1000 I am using the latest Chrome. Still having a tough time with this! |
SOLVED! Per this StackOverflow comment, the string I am able to change function sanitizeUrl(url) {
return url.replaceAll('&', '&')
} I would consider this issue closed. |
i faced the same issue. thank you very much! @zachsiegel-capsida |
My MWE is a very simple iframe:
This works just fine (full
iframe
code below).If I wrap the
src
attribute's value in curly braces (code below), I get the following:The actual
iframe
content is an embedded Powerpoint presentation:React version:
Steps To Reproduce
src="https://..."
in curly braces:src={"https://..."}
and save the component. Now theiframe
does not load! You can see the screenshots below to observe this phenomenon:The current behavior
My real example is something like
src={url}
, whereurl
is a state variable. The issue is not that I want to wrap the attribute in curly braces, it's that this iframe loads differently when the attribute is hard-coded into the jsx versus loaded from javascript via curly braces{url}
.I also recognize that Microsoft's Powerpoint embedding logic may forbid cross-origin embedding, and I want to emphasize that this is clearly not the issue here despite the Chrome console message. If cross-origin embedding was the issue, the
iframe
should equally fail with or without curly braces.The expected behavior
I expect the
iframe
to load (or not load) the same way regardless of whether itssrc
attribute is passed as an HTML attribute in jsx (src="https://..."
) or as a jsx attribute (src={"https://..."}
).The text was updated successfully, but these errors were encountered: