I have a UI widget that needs to be put in an IFRAME both for performance reasons and so we can syndicate it out to affiliate sites easily. The UI for the widget includes tool-tips that display over the top of other page content. See screenshot below or go to the site to see it in action. Is there any way to make content from within the IFRAME overlap the parent frame's content?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Nest your current iframe and the suggested div, inside of a parent iframe, then drop in your parent iframe to 3rd parties, best of both worlds!
I couldn't find a way to make the content of the frame flow out of the frame, but I did find a way to hack around it, by moving the tooltip into the parent document and placing it above (z-index) the iframe.
The approach was:
1) find the iframe in the parent document
2) remove the tooltip element from where it is in the DOM, and add it to the parent document inside the element that contains your iframe.
3) you probably need to adjust the z-index and positioning, depending on how you were doing that in the first place.
You can access the parent document of an iframe using parent.document.
if you know the absolute top of value that tool top can have you can create a div that is the height of the content + the highest distance the tool tip will display in. Align the iframe to the bottom of the div. make sure the iframe and div are transparent. then the iframe content with the tool tip should display. Though this is setting your self up for the headache of making sure stuff like highlighting work the same in all browsers.
As far as I know it cannot be done. Why not use an XHR request and populate a div instead?
This may be off the mark either because it's unsuitable in light of your requirements, or it may not actually help (!), but it might be worth checking out UFrame. It's a kind of hybrid of iframe and div, and could probably be packaged up as a widget (your best bet would be to give clients a
<script>
tag which would suck in UFrame and the relevant markup). What I'm not sure about is whether you can achieve the overlay you require, but it's possibly worth a play around with. Sorry I can't be more specific but it's not something I've actually used myself, I just bookmarked it a while back for future reference.No it's not possible. Ignoring any historical reasons, nowadays it would be considered a security vulnerability -- eg. many sites put untrusted content into iframes (the iframe source being a different origin so cannot modify the parent frame, per the same origin policy).
If such untrusted content had a mechanism to place content outside of the bounds of the iframe it could (for example) place an "identical" login div (or whatever) over a parent frame's real login fields, and could thus steal username/password information. Which would suck.