I need a solution for auto-adjusting the width
and height
of an iframe
to barely fit its content. The point is that the width and height can be changed after the iframe
has been loaded. I guess I need an event action to deal with the change in dimensions of the body contained in the iframe.
相关问题
- Views base64 encoded blob in HTML with PHP
- 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
After I have tried everything on the earth, this really works for me.
index.html
I found this resizer to work better:
Note the style object is removed.
all can not work using above methods.
javascript:
html:
Env: IE 10, Windows 7 x64
Cross-browser jQuery plug-in.
Cross-bowser, cross domain library that uses
mutationObserver
to keep iFrame sized to the content andpostMessage
to communicate between iFrame and host page. Works with or without jQuery.Here are several methods:
AND ANOTHER ALTERNATIVE
TO HIDE SCROLLING WITH 2 ALTERNATIVES AS SHOWN ABOVE
HACK WITH SECOND CODE
To hide the scroll-bars of the iFrame, the parent is made "overflow:hidden" to hide scrollbars and the iFrame is made to go upto 150% width and height which forces the scroll-bars outside the page and since the body doesn't have scroll-bars one may not expect the iframe to be exceeding the bounds of the page. This hides the scrollbars of the iFrame with full width!
source: set iframe auto height