Thursday, January 18, 2018

How do you use window.postMessage across domains?

You should post a message from frame to parent, after loaded.
This problem comes when One Application is running and another application has been added as <frame>.
Then when we click on the another application buttons then the page will not show the Main Application content .. 
If we want to show the main Application content .
we should do the following way ..

In Main Application Page put the following .
function listenMessage(msg) {
  $("html,body").animate({scrollTop:0},"show")
}

if (window.addEventListener) {
    window.addEventListener("message", listenMessage, false);
else {
    window.attachEvent("onmessage", listenMessage);

}
In Another Application which is added as <frame> add the following at the place where we click the buttons ..

$(document).ready(function() {
    
$("#buttonID").click(function(){
  window.parent.postMessage("I'm loaded""*");
}
});


No comments:

Post a Comment

Recent Post

Databricks Delta table merge Example

here's some sample code that demonstrates a merge operation on a Delta table using PySpark:   from pyspark.sql import SparkSession # cre...