What do I have to change to get this to work?

Discussion in 'Javascript' started by Iver Erling Årva, Jan 12, 2006.

  1. This works:

    Main window:
    <html>
    <head>
    <title>Untitled Document</title>
    <script>
    function openSub(){
    window.open("Printwindow.htm","pw","height=200px, width=300px, left=300px,
    top=300px")
    }
    </script>
    </head>

    <body>
    <form id='form1' name="form1">
    <input type="text" name="textfield">
    <input type="button" name="Test" value="Test" onClick="openSub();">
    </form>
    </body>
    </html>

    Sub window:
    <html>
    <head>
    <title>Untitled Document</title>
    <script type="text/javascript">
    function sendMe(txt){
    opener.form1.textfield.value=txt;
    }
    </script>
    </head>

    <body>
    <form name="frm">
    <input name="btn1" type="button" onClick="sendMe('test');" value="Test">
    </form>
    </body>
    </html>

    but if I change the window.open to window.showModalDialog it doesn't work
    any more. How do I send stuff back to the calling window if the callee has
    been opened as a modaldialog window?

    Thanks
     
    Iver Erling Årva, Jan 12, 2006
    #1
    1. Advertising

  2. Iver Erling Årva

    VK Guest

    Iver Erling Årva wrote:
    > How do I send stuff back to the calling window if the callee has
    > been opened as a modaldialog window?


    By closing your ModalDialog. ;-)
    var userChoice = window.showModalDialog(args);

    Why do you think it's called "modal" and "dialog"? It is just
    Microsoft's proprietary (though useful) way to display rich formatted
    dialog windows. But by its nature and execution mechanics it's the same
    as:
    var userChoice = window.confirm('OK or Cancel?');
     
    VK, Jan 12, 2006
    #2
    1. Advertising

  3. Iver Erling Årva wrote:

    > This works:
    >
    > Main window:
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <script>
    > function openSub(){
    > window.open("Printwindow.htm","pw","height=200px, width=300px,
    > left=300px,
    > top=300px")


    Should be ended with a semi-colon ...

    > }
    > </script>
    > </head>
    >
    > <body>
    > <form id='form1' name="form1">


    .... and is not Valid anyway.

    <URL:http://validator.w3.org/>

    > [...]
    > Sub window:
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <script type="text/javascript">
    > function sendMe(txt){
    > opener.form1.textfield.value=txt;
    > }
    > </script>
    > </head>
    >
    > <body>
    > <form name="frm">


    It is much the same here.

    > <input name="btn1" type="button" onClick="sendMe('test');" value="Test">
    > </form>
    > </body>
    > </html>
    >
    > but if I change the window.open to window.showModalDialog it doesn't work
    > any more.


    In fact, it is rather surprising it already worked without that. For
    window.open(), features in the third argument for window.open() are to
    be comma-separated, not comma-space-separated.

    <URL:http://docs.sun.com/source/816-6408-10/window.htm#1202731>
    <URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>

    And the syntax is different for IE-only window.showModalDialog(): the
    features have to be separated by semi-colon there:

    <URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp>

    > How do I send stuff back to the calling window if the callee has
    > been opened as a modaldialog window?


    As was said, by closing it.


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 12, 2006
    #3
  4. Iver Erling Årva

    VK Guest

    VK wrote:
    > Iver Erling Årva wrote:
    > > How do I send stuff back to the calling window if the callee has
    > > been opened as a modaldialog window?


    Actually check for showModelessDialog instead and
    dlgObject.dialogArguments property
    <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodelessdialog.asp>

    If you have more questions of their usage I guess they are better
    suited for microsoft.public.scripting.jscript as not too many people
    here ever used them actively (?)
     
    VK, Jan 12, 2006
    #4
  5. >> How do I send stuff back to the calling window if the callee has
    >> been opened as a modaldialog window?


    > As was said, by closing it.


    The problem is that unfortunately closing it is not an option. The window is
    generated by a program that opens a modal window and uses it to show a print
    preview. If it is a big report, it can take long to display the first page
    and I therefore want to send information back to the opener so it can
    display some sort of progress status info while the report is being
    generated. The good thing is that I have access to part of the code and
    therefore could add code to send stuff back, but part of the code is an
    active x and isn't mine. It is in that part the window is opened - hence I
    cannot change the way it is done.






    "Thomas 'PointedEars' Lahn" <> skrev i melding
    news:...
    > Iver Erling Årva wrote:
    >
    >> This works:
    >>
    >> Main window:
    >> <html>
    >> <head>
    >> <title>Untitled Document</title>
    >> <script>
    >> function openSub(){
    >> window.open("Printwindow.htm","pw","height=200px, width=300px,
    >> left=300px,
    >> top=300px")

    >
    > Should be ended with a semi-colon ...

    Yes, I know.
    >
    >> }
    >> </script>
    >> </head>
    >>
    >> <body>
    >> <form id='form1' name="form1">

    >
    > ... and is not Valid anyway.
    >
    > <URL:http://validator.w3.org/>
    >
    >> [...]
    >> Sub window:
    >> <html>
    >> <head>
    >> <title>Untitled Document</title>
    >> <script type="text/javascript">
    >> function sendMe(txt){
    >> opener.form1.textfield.value=txt;
    >> }
    >> </script>
    >> </head>
    >>
    >> <body>
    >> <form name="frm">

    >
    > It is much the same here.
    >
    >> <input name="btn1" type="button" onClick="sendMe('test');" value="Test">
    >> </form>
    >> </body>
    >> </html>
    >>
    >> but if I change the window.open to window.showModalDialog it doesn't work
    >> any more.

    >
    > In fact, it is rather surprising it already worked without that. For
    > window.open(), features in the third argument for window.open() are to
    > be comma-separated, not comma-space-separated.
    >
    > <URL:http://docs.sun.com/source/816-6408-10/window.htm#1202731>
    > <URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>
    >
    > And the syntax is different for IE-only window.showModalDialog(): the
    > features have to be separated by semi-colon there:
    >
    > <URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/showmodaldialog.asp>
    >
    >> How do I send stuff back to the calling window if the callee has
    >> been opened as a modaldialog window?

    >
    > As was said, by closing it.
    >
    >
    > PointedEars
     
    Iver Erling Årva, Jan 13, 2006
    #5
  6. Iver Erling Årva wrote:

    >>> How do I send stuff back to the calling window if the callee has
    >>> been opened as a modaldialog window?

    >>
    >> As was said, by closing it.


    Please provide attribution of quoted material.

    > The problem is that unfortunately closing it is not an option. The window
    > is generated by a program that opens a modal window and uses it to show a
    > print preview. If it is a big report, it can take long to display the
    > first page and I therefore want to send information back to the opener so
    > it can display some sort of progress status info while the report is being
    > generated. The good thing is that I have access to part of the code
    > and therefore could add code to send stuff back [...]


    It is nonsense to block the UA this long. So do not use a modal dialog
    here, and modify the code so that it does not open one in the first place.

    > [Top post]


    Please learn to quote.

    <URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>


    PointedEars
     
    Thomas 'PointedEars' Lahn, Jan 13, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. craig dicker
    Replies:
    9
    Views:
    682
    Juan T. Llibre
    Jul 7, 2005
  2. =?Utf-8?B?cmdyYW5kaWRpZXI=?=

    Can I have base class derived from System.Web.UI.Page have design

    =?Utf-8?B?cmdyYW5kaWRpZXI=?=, Jul 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    484
    Patrice
    Jul 22, 2005
  3. okaminer
    Replies:
    3
    Views:
    307
    okaminer
    Aug 1, 2005
  4. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    6
    Views:
    5,498
    Kevin Spencer
    Aug 18, 2005
  5. Xeno Campanoli
    Replies:
    1
    Views:
    345
    James Britt
    Jul 1, 2005
Loading...

Share This Page