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

I

Iver Erling Årva

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
(e-mail address removed)
 
V

VK

Iver said:
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?');
 
T

Thomas 'PointedEars' Lahn

Iver said:
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.

[...]
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:

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
 
I

Iver Erling Årva

How do I send stuff back to the calling window if the callee has
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.

(e-mail address removed)




Thomas 'PointedEars' Lahn said:
Iver said:
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.

[...]
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:

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
 
T

Thomas 'PointedEars' Lahn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top