Skip to content

Instantly share code, notes, and snippets.

@andersevenrud
Created June 24, 2016 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersevenrud/6209484db09267c01ca5545c75271948 to your computer and use it in GitHub Desktop.
Save andersevenrud/6209484db09267c01ca5545c75271948 to your computer and use it in GitHub Desktop.
OS.js Iframe Application bi-directional API script (Iframe Example)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src="iframeapi.js"></script>
<script>
// The event emitted when everything is loaded
OSjs.on('init', function() {
console.log(arguments);
// Send something
OSjs.send({cool: 'Awesome'});
});
// The event emitted when app is closed
OSjs.on('destroy', function() {
});
// Whenever you get data without `message` parameter
OSjs.on('data', function(data) {
console.log(data.zazz); // === "jazz"
});
// Whenever you get data with `message` set
OSjs.on('message:something', function(data) {
console.log(data.bar); // === "baz"
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment