[thelist] [re;] JS window.returnValue [solved]

James Aylard evolt at pixelwright.com
Tue Sep 9 10:00:43 CDT 2003


Tom Dell'Aringa wrote:

> Gah, 5 minutes after... found the solution, at the following page if
> you are interested:
>
> http://cita.rehab.uiuc.edu/scripting/newwindow/alert/page1.html


    On the IE-HTML list sometime back, contributor Joe Fawcett provided
another very
interesting (and, to my knowledge, otherwise explicitly documented) way to
pass data into and out of modal dialogs [1]. Essentially, you assign the
"opener" [2] as the argument passed into the modal dialog box. This allows
the modal dialog to directly update a variable in the "opener" document
regardless of whether it also sets a returnValue.
    Briefly:

"Opener" pseudo-code:
---------------------

<html>
  <head>
    <title>Parent document</title>
    <script type="text/javascript">
      var vTestData, vRv ;

      vTestData = "I am a rock" ;

      function fnShowModal()
      {
        vRv = window.showModalDialog("modalWindow.html", window.self, "") ;
      }

      function fnShowValue()
      {
        alert("vTestData = [" + vTestData + "]\nvRv = [" + vRv + "]") ;
      }

      fnShowValue() ; // The original value and an undefined return value
      fnShowModal() ; // Pop the modal
      fnShowValue() ; // The modified value and the return value

    </script>
  </head>
</html>

Modal pseudo-code:
------------------

<html>
  <head>
    <title>Modal Dialog</title>
    <script type="text/javascript">
      dialogArguments.vTestData += ", I am an island" ;
      window.returnValue = "I can be something else" ; // optional
    </script>
  </head>
  <body>
    <input type="button" onclick="window.close();">
  </body>
</html>


    Might be worth a look.

1.
http://microsoft.ease.lsoft.com/scripts/wa-msn.exe?A2=ind0207b&L=ie-html&T=0
&F=&I=-3&S=&P=1957
2. I put the word "opener" in quotes because modal dialogs don't actually
have a value for the opener property.

James Aylard
evolt at pixelwright.com



More information about the thelist mailing list