Socket
Book a DemoInstallSign in
Socket

@trendmicro/react-iframe

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trendmicro/react-iframe

React Iframe component

1.0.1
latest
Source
npmnpm
Version published
Maintainers
4
Created
Source

react-iframe build status Coverage Status

NPM

React Iframe

Demo: https://trendmicro-frontend.github.io/react-iframe

Installation

  • Install the latest version of react and react-iframe:
npm install --save react @trendmicro/react-iframe
import Iframe from '@trendmicro/react-iframe';

Usage

Fixed Iframe Height

<Iframe src="index.html" width="100%" height={240} />

Resize Iframe to Fit Content (Same Domain Only)

import ResizeObserver from 'resize-observer-polyfill';

<Iframe
    src="iframe.html"
    onLoad={({ event, iframe }) => {
        if (!(iframe && iframe.contentDocument)) {
            return;
        }

        const target = iframe.contentDocument.body;
        const nextHeight = target.offsetHeight;
        iframe.style.height = `${nextHeight}px`;

        const observer = new ResizeObserver(entries => {
            const target = iframe.contentDocument.body;
            const nextHeight = target.offsetHeight;
            iframe.style.height = `${nextHeight}px`;
        });
        observer.observe(target);
    }}
/>

API

Properties

NameTypeDefaultDescription
srcstringThe src attribute specifies the address of the document to embed in the iframe.
widthstring or number'100%'The width attribute specifies the width of an iframe, in pixels.
heightstring or number'100%'The height attribute specifies the height of an iframe, in pixels.
sandboxboolean, object, or stringThe sandbox attribute enables an extra set of restrictions for the content in the iframe.
sandbox.allowFormsbooleantrueRe-enables form submission.
sandbox.allowModalsbooleantrueSandboxed frames will block modal dialogs by default.
sandbox.allowPointerLockbooleanfalseRe-enables APIs.
sandbox.allowPopupsbooleantrueRe-enables popups.
sandbox.allowSameOriginbooleantrueAllows the iframe content to be treated as being from the same origin.
sandbox.allowScriptsbooleantrueRe-enables scripts.
sandbox.allowTopNavigationbooleanfalseAllows the iframe content to navigate its top-level browsing context.
onLoadfunctionCallback invoked when the iframe has been loaded: ({ event: Event, iframe: HTMLElement })
onBeforeUnloadfunctionCallback invoked when the iframe is about to be unloaded: ({ event: Event, iframe: HTMLElement })
onUnloadfunctionCallback invoked when the iframe has unloaded: ({ event: Event })

License

MIT

Keywords

react

FAQs

Package last updated on 21 Dec 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.