From 17bb3bd162c290a0615b70bcae2518e56bd66981 Mon Sep 17 00:00:00 2001 From: Bhavul Gauri Date: Thu, 12 Mar 2015 02:14:58 +0530 Subject: [PATCH] added message sending recieving API doc --- javascripts/content_scripts/messagingJSON.md | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 javascripts/content_scripts/messagingJSON.md diff --git a/javascripts/content_scripts/messagingJSON.md b/javascripts/content_scripts/messagingJSON.md new file mode 100644 index 0000000..f14196b --- /dev/null +++ b/javascripts/content_scripts/messagingJSON.md @@ -0,0 +1,32 @@ +Sending and Recieving Messages API +======================================= + +Any injected application can send messages to the content script (privly.js) to trigger it to resize, show or hide the iframe content. JSON is used for this communication. Injected application can use the following blueprint for sending messages :- + +An example of a message could be: +``` +{command:"resize", + frameID:"name of iframe" + heightNEW:No. of pixels, + } +``` + +**A possible syntax for sending this message over the host would be:** +```javascript +var message = {command:"resize", + frameID:"name of iframe" + heightNEW:No. of pixels + }; + msgJSON = JSON.stringify(message); + parent.postMessage(JSON.stringify(resizeData),"*"); + ``` + +##Possible set of options + +* command : "resize" | "hide" | "show" +* frameID : "" +* heightNEW : no. of pixels + + +While using `hide` or `show` as the command, `heightNEW` doesn't matter and you may or may not include it in your message. +