1

I have a opened window called "http://192.168.17.109/report3_test/post-data" shown below.

enter image description here

Onclick Launch button I am passing textbox id and callback function here is the html and jquery function

HTML

 <form id="report">
          <div class="form-group">
              <center><label for="post-data"><h3>Reporting Data</h3></label></center>&nbsp;&nbsp;
              <textarea class="form-control" rows="20" id="post-data" name="post-data"></textarea>
          </div>
           <div class="form-group">
                  <div class="col-sm-6"><button type="submit" class="btn btn-primary btn-block" name="launch" id="launch" onclick="invoke_reporting(document.getElementById('post-data'),callback)">Launch</button>
                   </div>
            </div>
</form>

JavaScript

function invoke_reporting(textdata,callback) {
    window.open("http://192.168.17.109/report3_test/templates/ct-head");
    if (callback && typeof(callback) === "function") {
        callback(textdata,newwindow);
    }    
}

Here I am opening a this new window on click launch and it shown below http://192.168.17.109/report3_test/templates/ct-head

enter image description here

Onclick copy to clipboard button I want to send data back to already opened window shown on top that is "http://192.168.17.109/report3_test/post-data" and here is my callback method .

function callback(finaldata){

        var arr = $.parseHTML(finaldata);
        v
        Window.onload = function(){

            var test_data = "";
            for(var i=0; i<finaldata.length;i++)
            {
                if(i == 0){
                    var first_element = 'REPORT TITLE:' + '<br/>' + finaldata[0] + '<br/>' + '<br/>';
                    test_data += first_element.replace(/<br.*?>/g, '\n');
                }else if(i == 1){
                    var second_element = 'FINDINGS:' + '<br/>' + finaldata[1] + '<br/>' + '<br/>';
                    test_data += second_element.replace(/<br.*?>/g, '\n');

                }else{
                    var final_element =  'IMPRESSION:' + '<br/>' + finaldata[2];
                    test_data += final_element.replace(/<br.*?>/g, '\n');

                }
            }
        newWindow.document.getElementById('post-data').value = test_data;

    };
}

Any help would be appreciated.

Anand Huded
  • 641
  • 5
  • 12
  • Maybe try this: https://stackoverflow.com/questions/12129121/how-to-pass-data-to-parent-window-from-popup-window – norbert.mate Oct 18 '18 at 06:01
  • No. I am integrating my application with another application. post-data page will be there in other application from there I am redirecting to my current application pages like ct-head once data gets generated from this ct-head page that data should go back to post-data page. – Anand Huded Oct 18 '18 at 06:26
  • So you want to make communication between 2 different domains? I am not sure if the browser let you do that. – norbert.mate Oct 19 '18 at 10:58
  • Yes exactly similar. From parent window opening new window and sending data back from new window to parent window. – Anand Huded Oct 19 '18 at 12:20

0 Answers0