
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
iframe-resizer
Advanced tools
The iframe-resizer npm package provides a set of tools to automatically resize iframes to fit their content and to enable communication between the iframe and the parent page. It is useful for ensuring that iframes are displayed correctly without scrollbars and for passing data between the iframe and the parent page.
Automatic Resizing
This feature automatically resizes the iframe to fit its content. The `log: true` option enables logging for debugging purposes, and `#myIframe` is the selector for the iframe element.
const iFrameResize = require('iframe-resizer/js/iframeResizer');
iFrameResize({ log: true }, '#myIframe');
Height Calculation Methods
This feature allows you to specify different methods for calculating the height of the iframe. The `heightCalculationMethod` option can be set to various values like 'bodyScroll', 'documentElementScroll', 'max', etc. In this example, 'taggedElement' is used.
iFrameResize({ heightCalculationMethod: 'taggedElement' }, '#myIframe');
Message Passing
This feature enables sending messages from the parent page to the iframe. The `sendMessage` method is used to send a message to the iframe.
const iframe = iFrameResize({ log: true }, '#myIframe')[0];
iframe.iFrameResizer.sendMessage('Hello from parent');
Event Handling
This feature allows you to handle events such as resizing. The `resizedCallback` option is a function that gets called whenever the iframe is resized.
iFrameResize({
resizedCallback: function(messageData) {
console.log('Iframe resized:', messageData);
}
}, '#myIframe');
This package is a React wrapper for iframe-resizer, providing similar functionality but specifically designed for use with React applications. It simplifies the integration of iframe-resizer in React projects.
Another React-specific package that wraps iframe-resizer, making it easier to use within React components. It offers similar features but is tailored for React's component-based architecture.
This package is a legacy version of iframe-resizer. This project has now been split in to separate packages for the parent and child pages.
Their are now also versions of iframe-resizer for React, Vue, Angular and jQuery.
For more details please see: https://iframe-resizer.com/upgrade.
Copyright © 2013-25 David J. Bradshaw
FAQs
Keep iframes sized to their content.
The npm package iframe-resizer receives a total of 277,280 weekly downloads. As such, iframe-resizer popularity was classified as popular.
We found that iframe-resizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.