Notation and Conventions
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in
RFC2119. Domain name examples use
RFC2606.
Terminology
Observer - a client web application that is
JavaScript? enabled which registers event handlers to content elements
Embedded page - a URL-referencable HTML resource that provides client capabilities and dispatches events
iframe - an
element defined in HTML used for embedding browsable content
Protocol Selection
The observer selects which protocol the use and communicates it to the embedding page. The observer MUST supply the as part of the embedded page's URL a fragment identifier and the embedded page MUST use the designated protocol. Embedded pages MUST support both these protocols:
* "#oslc-postMessage-1.0" - MUST use the HTML5 postMessage method of communicating messages as defined in
postMessage protocol defintion.
* "#oslc-windowName-1.0" - MUST use the Window Object 1.0 window.name method of communication messages as defined in
Window.name protocol definition.
Example for testing for protocol selection
function respond(message){
var protocol = window.location.hash;
if (protocol == '#oslc-windowName-1.0'){
respondWithWindowName(message);
} else if(protocol == '#oslc-postMessage-1.0'){
respondWithPostMessage(message);
}
}
Protocol Definitions
'Post Message'
See
W3C HTML5 postMessage
Input |
protocol - passed in URL's fragment ( oslc-postMessage-1.0 ) |
Notification |
Observer listens for window 'message' events, ignoring events from other sources or not prefixed with "oslc-response:" |
Output |
response - passed in event.data string, must be prefixed with "oslc-response:" |
The 'Post Message' protocol relies on the function
window.postMessage()
, available in the latest or pending releases of most browsers (Firefox 3, Safari 4, IE 8). Observers must anticipate other, unrelated uses of postMessage(), and should ignore messages not conforming to this protocol.
Typically, the embedded page will be loaded in a window inside another window, such as a iframe inside some surrounding webpage. In such cases,
postMessage()
must be called on that parent window. But in a native application, an outer page is not needed and the embedded page may be shown directly in the browser's "root" window. When the embedded page has no parent window, it must call
postMessage()
on its own window.