PDA

Click to See Complete Forum and Search --> : Switching between windows in ASP - urgent


tompod
Jun 20th, 2000, 09:23 PM
Hello
In my ASP application I open a new window with command
<SCRIPT>
window2=window.open("xx.asp","secondwindow")
</SCRIPT>
Can anybody know how to close window2 and navigate back to main window (run an ASP in main window) using submit button in window2.
I tried:
<FORM action="osp.asp">
<INPUT type="SUBMIT" name="action" value="Close" onClick="window.close();window.opener.focus">
</FORM>
Window2 closes but osp.asp is not executed in main window.

Best regards,
Tomaz

Mark Sreeves
Jun 21st, 2000, 03:25 PM
Just a guess here, but have you tried specifying a target tag in the form

<FORM action="osp.asp" target="window1">



I'll have a play with this later if I get time.

tompod
Jun 21st, 2000, 03:57 PM
I tried
<FORM action="osp.asp" target="window1">
but it opens another browser instance.
"window1 " is default window adn is not opened by javascript
window.open().
I also tried
<FORM action="osp.asp" target="window.opener">
but it opens another browser instance too.

Best regards,
Tomaz

Mark Sreeves
Jun 21st, 2000, 05:46 PM
Here you are tompod

load default.htm into your browser...

default.htm

<html>


<frameset cols="*">
<frame name="main" src="osp.asp">
</frameset>
<noframes>
<p>This page uses frames, but your browser doesn't support them.</p>
</font></body>

</html>


osp.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>
<SCRIPT language='Javascript'>
function OpenPopup(){
window2=window.open('xx.asp','secondwindow','width=200,height=260')
}
</SCRIPT>

</HEAD>
<BODY>

<%

dim x
dim y

x = clng(Request("x"))
y = clng(Request("y"))

Response.Write "X+Y = " & x + y
Response.Write"<BR><input type=button value='Next' onClick='OpenPopup()'>"

%>

</BODY>
</HTML>




xx.asp

<%@ Language=VBScript %>
<HTML>
<HEAD>

</HEAD>
<BODY>
<FORM action="osp.asp" target="main">
<input name="x" value=2>
<input name="y" value=2>
<INPUT type="SUBMIT" name="action" value="Close" onClick="window.close();window.opener.focus">

</FORM>

<P>&nbsp;</P>

</BODY>
</HTML>

tompod
Jun 21st, 2000, 07:52 PM
Thank's Mark!
I works fine, but there is just one thing. I'm calling this asp from frame page with two frames
--------------------------
<html>

<frameset framespacing="2" rows="50%,50%" frameborder="1">
<frame name="main1" src="yy.asp">
<frame name="main2" src="osp.asp">
</frameset>
<noframes>
<p>This page uses frames, but your browser doesn't support them.</p>
</font></body>

</html>
----------------------------
I'n this case
----------------------------
<INPUT type="SUBMIT" name="action" value="Close" onClick="window.close();window.opener.focus">
----------------------------
stil opens another browser instance, instead of
display osp.asp in main window.

If you know how to fix that I vould be very pleased.

Thanks and best regards,
Tomaz

Mark Sreeves
Jun 21st, 2000, 08:03 PM
do you want osp.asp to
a)reload into the bottom frame or

b)reload and replace both frames?

if a) then it works OK (for me)just make sure you've got main2 as the target

if b), you'll need another frame page with one frame with the SRC set to the 2-frame frame page....

tompod
Jun 21st, 2000, 08:11 PM
Thank's Mark
I've just forgot to specifie "main2" frame as a target.
Now it works fine.
You helped me a lot!

Thank's again!
Tomaz