sending Messages from one domain to another using postMessage function in javascript -


If I open a domain in a browser. Example.com and www.example.com (cross domain) on other browsers ) Open Is it possible that a message can be sent from www.abc.com to chat.abc.com?

I tried the following:

The message to receive the script iewww.example.com on the receiver is as follows:

jqcc (document). Ready (function () {

  var eventMethod = window.addEventListener? "AddEventListener": "attachEvent"; var eventer = window [eventMethod]; var message event = event method = "activate"? "OnMessage": "Message"; // Listen Message from Child Window Eventener (messageEvent, function (e) {if (e.data.indexOf ("He") & Gt; = -1) {console.log ("Message Received: "+ e.data);}}, wrong);  

});

I try to send a message as

I have not found anything in the browser console . Please

No, this will not work.

Post Message The API is used only with iframes What do you want to do, www.chat.example.com inside Www.example.com is to open an iframe. Then, you can use the document.getElementById ('iframe_pointing_to_chat'). ContentWindow.postMessage ('Message', '*') .

Now, www.chat.example. Com will receive the message through on-message handler.


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -