Namespace $sf.lib.dom.msghost

$sf.lib.dom.msghost Contains functionality to reside in the top level page for sending and receiving x-domain messages to SafeFrame containers

Method Summary

Method Detail

  • <static> $sf.lib.dom.msghost.attach(el, pipe, cb)
    Listen for messages from an IFRAME. Note that on the host / publisher side this library only allows for one message handler to be attached to a given IFRAME.
    Parameters:
    {HTMLElement} el
    The IFRAME reference to attach a listener callback too. .
    {Object} pipe
    The message pipe object created from $sf.lib.dom.msghost.prep
    {Function} cb
    The callback function to fire when a message is received
  • <static> $sf.lib.dom.msghost.detach(el)
    Detach listening for messages from an IFRAME
    Parameters:
    {HTMLElement} el
    The IFRAME reference to detach a listener
  • <static> {Object} $sf.lib.dom.msghost.prep(attrs)
    Prepare an iframe in the top level window to be able to send / receive cross-domain messages Generally this method is called from $sf.lib.iframes. The attrs object in question should represent key/value pairs of HTML attributes for the iframe. Note that the attrs object passed in will be modified with a new "name" property, to send information into the iframe and setup messaging.
    Parameters:
    {Object} attrs
    Information required to set up the cross-domain messaging channel
    {String} attrs.id
    The IFRAME HTML id attribute
    {String} attrs.src
    The URL / src attribute of the IFRAME
    {String} attrs.guid Optional
    The guid / signature to use to validate that messages sent/ received can be accepted. If not specified, one will be created automatically.
    {String} attrs.name Optional
    The IFRAME HTML name attribute which will be used to send an intial message to the HTML document inside the IFRAME.
    Returns:
    {Object} An object with various properties detailing the messaging pipe-line.
  • <static> {Boolean} $sf.lib.dom.msghost.send(tgtID, data)
    Send a message to a child iframe.
    Parameters:
    {String} tgtID
    The HTML id attribute of the iframe element for which to send a message
    {String} data
    The string of data to send to the given iframe
    Returns:
    {Boolean} Whether or not message was send succesfully (note that this does not mean message was handled / recevied, only that sending was ok).
  • <static> {Boolean} $sf.lib.dom.msghost.usingHTML5()
    Get whether or not HTML5 style messaging can be used
    Returns:
    {Boolean}