Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 1.62 KB

README.md

File metadata and controls

58 lines (40 loc) · 1.62 KB

#Seamless Polyfill

A Javascript polyfill for the HTML5 iframe's seamless attribute.

This is a polyfill for the iframe seamless attribute which does not currently have much support amongst stable browsers. In order to give us a similar effect, this polyfill will use the window.postMessage method to send information about the iframe's scrollHeight so it can be used by the parent to adjust the height of the iframe.

Usage

Seamless is compatible with AMD and CommonJS module loaders. You can also just include seamless.js manually to create a global seamless object.

You can install this package using bower or npm.

bower install seamless-polyfill

or

npm install seamless-polyfill

On any page that will be loaded in a frame, call seamless.frame.

seamless.frame({
    'allowed_domains': ['http://localhost:5000'],
    'target_origin': '*'
});

On any page that contains frames, call seamless.parent.

seamless.parent({
    'allowed_domains': ['http://localhost:5000'],
    'target_origin': '*'
});

Any iframes on the parent page with the seamless attribute set will be effected. seamless is a boolean attribute so it does not require a value. Simply set it as:

<iframe src="..." frameborder="0" seamless>

Arguments

  • allowed_domains: Domain whitelist used for window.postMessage. If the domains of the frame and parent are not included, one or both will not respond to messages.
  • target_origin: targetOrigin value used for window.postMessage. Defaults to *.