|Targetting a window |
| 3:19 pm on Sep 27, 2002 (gmt 0)|
Take the following (simplified) example: <form name="testform" method="post" action="test.asp">
<input type="hidden" name="field" value="whatever">
<input type="button" value="go post" onclick="goPost2()">
myWin = window.open("page.htm","myWin","width=300")
document.testform.target = "myWin";
The form submit targets a new (like a _blank) window. I've tried everything including adding a delay (up to 8 seconds!) after the open. I've written the code a thousand different ways (without 'myWin =' etc, using a normal submit button and target attribute). I've installed IE5.0 SP2 without luck, upgraded to IE5.5 SP2 and it still didn't work. IE6 nada. The script engine is 5.6 (latest version) and yet it still refuses to target the window opened by script.
The window knows that it's name is myWin as I've used: document.write(window.self.name) in page.htm.
Please help me before I pull it all my hair, give myself concussion and damage the wall.
| 4:11 pm on Sep 27, 2002 (gmt 0)|
I am using the following code and it works always fine:
<form action="file.php" method="post" target="mywin" onSubmit="window.open('', 'mywin', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes')">
| 4:23 pm on Sep 27, 2002 (gmt 0)|
I really can't explain this and just assumed it an IE bug, but we've upgraded the browser three times and it's still there (they're W2K boxes).
| 4:30 pm on Sep 27, 2002 (gmt 0)|
It is necessary that you write the windows name in each of the targets. In form tag it is e.g.
onSubmit="window.open('', 'yourwindow', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes')"
| 7:56 am on Sep 30, 2002 (gmt 0)|
And I've tried it with the attribute on the <form> tag itself but it still isn't working no these two machines. I even cut and pasted your code and tried it - it didn't work.
This is baffling everyone I've had look at it. When it happened on one machine at first we kind of just put it down to a 'freak' event on a rogue machine... until we got another call.
Our concern is that going from the stats here we could be looking at 4% of users (admittedly, 2 out of 50 isn't the strongest basis for such a statistical analysis but thats our concern nonetheless).
Anybody heard of anything like this?
[edited by: joshie76 at 8:05 am (utc) on Sep. 30, 2002]
| 8:04 am on Sep 30, 2002 (gmt 0)|
Are these the 2 only IE machines in your 50? It would (maybe) help to know what's different on those 2 machines compared to the 48 others.
| 8:08 am on Sep 30, 2002 (gmt 0)|
Machines here are built, like most other offices from a standard ghost. I've hunted through the installed programs and plug-ins but there's nothing out of the ordinary...
All machines have IE on them (various versions, one per machine).
| 8:30 am on Oct 2, 2002 (gmt 0)|
Oddly enough I wrestled the same prob this eve & wuz reading your post, then found this link... and wah-lah. Worked for me :)
What I don't see you doing, is setting a RETURN in your onSubmit, and in the JS function. As this link points out, the RETURN is what allows the blank window to open, before returning control back to the FORM tag with ACTION= .asp file.
Hope this helps, I grab tips off these Forums alot & it would be cool to give one for a change...
| 10:51 am on Oct 2, 2002 (gmt 0)|
Hi Railbird and welcome to the forums,
Unfortunatley I've tried the return method and just tested your exact code but these two machines still refuse to target the pop-up window.
If you really think about it programmatically then "the RETURN is what allows the blank window to open, before returning control back to the FORM tag with ACTION= .asp file." doesn't hold programmatically (especially if you consider the first example I posted with an added delay before the submit) but I'll try anything once. It's funny fixes like this that often sneak through.... no such luck.
I'm totally exhaused on this one. It would help If I knew the scale of the problem or whether it's just these two machines.
Thanks for trying tho'
| 4:43 pm on Nov 15, 2002 (gmt 0)|
I have the same problem that Josie76 encountered.
Here's a sample of my code :
document.all["frm"].target = sTarget;
var sTarget = document.all["frm"].target;
if (sTarget == "MyPopUp")
var sFeatures = "resizable=yes,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes";
sFeatures += ",width=" + screen.availWidth * 0.80;
sFeatures += ",height=" + screen.availHeight * 0.80;
sFeatures += ",left=" + screen.availWidth * 0.10;
sFeatures += ",top=" + screen.availHeight * 0.10;
var win = window.open("", "MyPopUp", sFeatures);
<FORM ID="frm" ACTION="mytargetpage.asp" METHOD="POST" TARGET="MyFrame" onSubmit="return JS_OnSubmit();">
<INPUT ID="btnExecute1" TYPE="SUBMIT" VALUE="Execute 1" onClick="JS_SetTarget('MyFrame')">
<INPUT ID="btnExecute2" TYPE="SUBMIT" VALUE="Execute 2" onClick="JS_SetTarget('MyPopUp')">
The goal is to display the content of mytargetpage.asp in a frame if btnExecute1 is pressed or in
a new window if btnExecute2 is pressed.
The POST method is used, because one of the parameters sent to mytargetpage.asp is a SQL query, which can be
very long and can embedded some problematic chars like '+'...
On some machine, this code works well. On others, a blank window is first opened (named 'MyPopUp') and
then a second one is opened, and the second one has the role of target!
NB: A greater value of timeout has no effect on this problem.
If someone could help...
Thanx in advance.