Discussion:
Response Redirect and close window
(too old to reply)
Aleks
2004-11-30 17:30:48 UTC
Permalink
Hi,

Is it possible to redirect to another page and close the current window
using response.redirect ?

This is because I have a popup window open and after an insert I need the
window to close and refresh "Updatecasedetails.asp" passing the URL
parameter of course.

I tried this:

<%
Response.Redirect("GeneralInfo/Updatecasedetails.asp?caseId=" &
Cases.Fields.Item("Id").Value);self.close()
%>

But I get an error:

personnel)
a.. Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/blueDOTbeta/Intranet/Cases/Receipts/AddReceipt.asp, line 299, column 94
Response.Redirect("GeneralInfo/Updatecasedetails.asp?caseId=" &
Cases.Fields.Item("Id").Value);self.close()
---------------------------------------------------------------------------------------------^


Aleks
Chris In Madison
2004-11-30 17:35:49 UTC
Permalink
Yeah, that's pretty much not going to work. You're trying to do server and
client-side code at the same time. The logic you've employed here will
redirect the pop-up window to some page then close the pop-up window (if it
would work, but it won't).

You might need to do something with window.opener to get this to work the
way you want it. Something like this in your pop-up:

<script language="javascript">

window.opener.location.href="GeneralInfo/Updatecasedetails.asp?caseId=<%=Cas
es.Fields.Item("Id").Value%>";
self.close();
</script>

Just pulling that out of the air as a concept. You'll probably need to mess
with it to get it to work as you'd like.

Best regards,
Chris
Brandon Taylor
2004-11-30 17:41:39 UTC
Permalink
You'd have to open the window with JS and then close the window.opener from
the pop-up because you can't target a response.redirect into a new window,
AFAIK.

bT
Post by Chris In Madison
Yeah, that's pretty much not going to work. You're trying to do server and
client-side code at the same time. The logic you've employed here will
redirect the pop-up window to some page then close the pop-up window (if it
would work, but it won't).
You might need to do something with window.opener to get this to work the
<script language="javascript">
window.opener.location.href="GeneralInfo/Updatecasedetails.asp?caseId=<%=Cas
es.Fields.Item("Id").Value%>";
self.close();
</script>
Just pulling that out of the air as a concept. You'll probably need to mess
with it to get it to work as you'd like.
Best regards,
Chris
Aleks
2004-11-30 17:42:03 UTC
Permalink
Thanks,

Problem is the page is VB, I added the code as you have it below and got
this error:

The page cannot be displayed
There is a problem with the page you are trying to reach and it cannot
be displayed.

--------------------------------------------------------------------------

Please try the following:

a.. Click the Refresh button, or try again later.

b.. Open the localhost home page, and then look for links to the
information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------

Technical Information (for support personnel)

a.. Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/blueDOTbeta/Intranet/Cases/Receipts/AddReceipt.asp, line 320
=Cas


b.. Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
{3A817C4D-DE3C-4405-B12B-8E89629A7DBC}; SV1; .NET CLR 1.1.4322)

c.. Page:
GET /blueDOTbeta/Intranet/Cases/Receipts/AddReceipt.asp

d.. Time:
Tuesday, November 30, 2004, 12:40:53 PM


e.. More information:
Microsoft Support
Brandon Taylor
2004-11-30 17:56:39 UTC
Permalink
It doesn't matter what the page type is, you can combine whatever scripting
language you want, in this case, VB or VB Script, as long as you keep them
separate syntactically. You can't switch syntaxes in the middle and expect
the computer to know what language you want it to use, unless you tell it
;-)

Example:

<%
do sql
saved = true
%>

<script language="javascript">
<% if saved then %>
window.open("somepage.asp","detailWindow","width=760,height=420")
<% end if %>
</script>

then in "somepage.asp" you would have a script that fired when the page
loaded, like:

window.opener.close()

When the original page is rendered, the only time the window.open() will
actually execute is if the condition "saved" = true, which in this case, is
after some SQL is executed. JavaScript can target whatever you want, VB
Script can not.

HTH,
bT
Post by Aleks
Thanks,
Problem is the page is VB, I added the code as you have it below and got
The page cannot be displayed
There is a problem with the page you are trying to reach and it
cannot be displayed.
--------------------------------------------------------------------------
a.. Click the Refresh button, or try again later.
b.. Open the localhost home page, and then look for links to the
information you want.
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------
Technical Information (for support personnel)
Microsoft VBScript compilation (0x800A0400)
Expected statement
/blueDOTbeta/Intranet/Cases/Receipts/AddReceipt.asp, line 320
=Cas
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
{3A817C4D-DE3C-4405-B12B-8E89629A7DBC}; SV1; .NET CLR 1.1.4322)
GET /blueDOTbeta/Intranet/Cases/Receipts/AddReceipt.asp
Tuesday, November 30, 2004, 12:40:53 PM
Microsoft Support
Julian Roberts
2004-11-30 17:56:59 UTC
Permalink
You could have some code like this

Response.redirect "closewindowpage.asp"

and on the closewindow page:

<script>
window.opener.location.reload();
window.close();
</script>
--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004
Aleks
2004-11-30 18:10:36 UTC
Permalink
thx
Post by Julian Roberts
You could have some code like this
Response.redirect "closewindowpage.asp"
<script>
window.opener.location.reload();
window.close();
</script>
--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004
Loading...