Created
June 24, 2016 21:48
-
-
Save andersevenrud/6209484db09267c01ca5545c75271948 to your computer and use it in GitHub Desktop.
OS.js Iframe Application bi-directional API script (Iframe Example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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