Jump to content

Frame Broadcast Message to Parent.


MOGSY

Recommended Posts

4 hours ago, MOGSY said:

Hi

self.Parent.Broadcast(aParam);

There is method to broadcast message to parent of a Frame. Has anyone have an example of how to use it and receive the message at parent.

Thank you

Regards.

Hi, instead BroadCast please use "window.parent.postMessage" in iFrame.

Use below code in uniGUI to receive posted message.

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniSession.AddJS('function receiveMessage(event){'+
                   '  ajaxRequest('+WebForm.JSName+', "Message", event.data);'+
                   '}'+
                   'window.addEventListener("message", receiveMessage, false);');
end;
procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='Message' then
  begin

  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...