iframe-transport

Thin postMessage wrapper for processing method calls, callbacks, and events

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
iframe-transport
0.0.18 years ago8 years agoMinified + gzip package size for iframe-transport in KB

Readme

iframe-transport

Bi-directional RPC over iframe. Targets modern browsers, IE8+.
ift.parent({
  childOrigin: 'http://childapp.com',
  childPath: '/child.html'
}).ready(function(manager) {
  var channel = manager.channel('test');
  channel.request('hello', ['child!'], function(response) {
    console.log(response); // hello parent!
  });
});

ift.child({
  trustedOrigins: ['http://parentapp.com']
}).ready(function(manager) {
  var channel = manager.channel('test');
  channel.on('request', function(id, method, params) {
    console.log(method, params[0]); // hello child!
    channel.respond(id, 'hello parent!');
  });
});

Services

LocalStorage Service
Persist data across domains.

Example

Start two servers, one on port 8000 and one on port 4000:
$ http-server -p 8000
$ http-server -p 4000

Open http://127.0.0.1:8000/example/parent.html

Tests

$ npm test
Sauce Labs
$ npm run test-sauce