travist / seamless.js

A Javascript library for working with seamless iframes.
http://www.travistidwell.com/seamless.js
MIT License
216 stars 44 forks source link

What is postmessage, and what do I need it for? #17

Open ghost opened 7 years ago

ghost commented 7 years ago

When using either the parent or child version of seamless.js I get the following message in the console: You must install the postmessage.js module to use seamless.js. I did not find a mention of postmessage in the install instructions.

I tried using seamless.child.nopm.js because I assumed that "nopm" would mean "no postmessage", but the result is the same.

I am using Seamless 1.2.0.

raochoar commented 6 years ago

Any thought ?

rohanrp commented 4 years ago

There is a weird bug where seamless initialises postmessage under the 'pm' property of the window object. But in some cases where seamless is called directly by another script, the window object is not passed in. It kind of expects seamless to be called by the html document so that the script runs under the window context i.e. this = window

if you are using webpack try

const seamless = require('!raw-loader!seamless/build/seamless.parent.min.js');
eval.call(null, seamless.default);

or via a promise

import('!raw-loader!../../../node_modules/seamless/build/seamless.parent.min.js').then(rawModule => {
eval.call(null, rawModule.default);