tultalk has asked for the wisdom of the Perl Monks concerning the following question:

Hi:

First, I have problem deciding what say in search to find stuff. Nor very successful using the search here.Usually google then look at the monks results.

In code preceding that below, I do this and that producing a result I send back to an iFrame on the calling form.

I have function (cgi call )on that form to load the result into the iFrame. Works fine when I click the button to call the function.

I have listener on the calling form and i want to execute the call to get the result into the iFrame from a windows message posted from the cgi script (below) after the messages are ready.

Don't know how to address the form. I don't think it is the window.parent of the cgi script. Help.

Best regards

window.parent.postMessage({ 'func': 'GetFileLoadStatus', 'message': 'Message text from iframe.' }, "*"); if ($action eq "updatereport"){ warn("In updatereport before CreateDataFeedbackForm"); CreateDataFeedbackForm($message, $filemessage); }

Replies are listed 'Best First'.
Re: send windowmessage from cgi back to form that called the cgi
by Corion (Patriarch) on Mar 14, 2017 at 14:42 UTC

    Does your stuff happen in the client browser on the client machine or on the server machine?

    If it happens in your client browser, you cannot do this with Perl.

      That was quick.

      The "stuff" is generated by the script on the server (accessing MySQL). The script is called from the form where the results are loaded into the iFrame. I can get the results by the call to the CGI ...nt.cgi?action=updateReport. I want to do this automatically when the script producing the results finishes.

        This is more java JavaScript related than perl, but i have a page where i want to execute java JavaScript when it loads. based on what it does so you could try

        print $q->header( -type =>'text/html'); print <<"EODEOD"; <title>mytitle</title> <script language="JavaScript"> <!-- function iframeLoad(a) { window.parent.postMessage({ 'func': 'GetFileLoadStatus', 'message': 'Message text from iframe.' }, "*"); } //--> </script> <body onload="iframeLoad()"> EODEOD

        Edit: a was just a temp var, my sub was

        function iframeLoad(a) { a = document.getElementById("tableId").innerHTML; parent.document.getElementById("tableId").innerHTML = a; parent.document.getElementById("hiframe").src = "about:blank"; }
        In the parent i had
        ... function showTable(loc) { document.getElementById("tableId").innerHTML="Waiting on:" + loc; document.getElementById("hiframe").src = loc; } ... <input type="button" value="run program" onclick="showTable('/cgi-bin/ +program.pl?parm1=1')"> <iframe id="hiframe" src="about:blank" style="visibility:hidden;displa +y:none"></iframe> <div id="tableId" style="background-color:lightgray"></div> ....
        and the cgi call also returned
        .... <div id="tableId"> <pre> some stuff to display more stuff </pre></div>