Web messaging

[edsanimate_start entry_animation_type= “flipInX” entry_delay= “1” entry_duration= “1” entry_timing= “ease-in” exit_animation_type= “” exit_delay= “” exit_duration= “” exit_timing= “” animation_repeat= “1” keep= “yes” animate_on= “load” scroll_offset= “” custom_css_class= “”]

The web messaging or cross-document messaging allows files or data to access from one domain to other domains.

The cross scripting protects the web browser from web attacks.

The code is designed for cross site scripting attacks.

The use of the API is to protect the user.

The method event which is being received has the following attributes

  • data
  • origin
  • source

Sending messages to other page by using postMessage() method is

var messageiframe = document.getElementById(“messageiframe”);

messageiframe.contentWindow.postMessage(“Welcome”, “http://bytatek.com”);

The message received using addEventListener() method is

function getMessage(event)

{

if(event.origin !== “http://bytatek.com”)

return;

event.source.postMessage(“welcome message”, event.origin);

}

window.addEventListener(“message”, getMessage, false);

[edsanimate_end]