View Full Version : response.redirect w/ target


Steve Wood
10-07-2004, 07:29 PM
Is it possible for a WAS page to set a target (e.g. target=_blank) as part of response.redirect()? I find comments on the web that this is difficult to accomplilsh.

Selwyn Rabins
10-08-2004, 07:59 AM
no you can't.

response.redirect is used to tell the current window what to display.

remember, the current window has to display SOMETHING.

also, remember, only the user (or javascript that runs on the user's browser) can cause a new browser window to open. the server cannot cause a new window to open on the client. response.redirect is a server command.

this is not a limitation, and it is not unique to a5. it would be true no matter what tool you were using - e.g. asp, coldfusion, etc.

Lenny Forziati
10-08-2004, 08:06 AM
A response.redirect cannot do this. The reason is that a specific window has requested a page (which in this case is being redirected to a different page) and the result can only be sent to the page which made the request.

What you are trying to achieve can be done, but it is a bit complex. Something must be sent back to the window which made the request. I don't know what you want to display there, but probably just the same page. In this page that you send back, you would also need to include some javascript code that opened a new window and in that window made the request for the actual page you are trying to open. Take a look at the onLoad event for the BODY and Javascript's window.open()


Steve Wood
10-08-2004, 09:31 AM
Thanks, I'll play around with it. I've used onload and window.open javascript in the past (through Dreamweaver) to open a new browser window. I can see why it is difficult to program, and its not urgent, but wanted to add this point below...

I think it is important at the 'presentation level' for users to expect reports to open a window other than the WAS application window. Users get lost as they spend time with the report -- analysis, printing, reading, etc. When done they do the natural thing and close [X] the report, thereby closing the Alpha application. More often, users want to compare information in the report side-by-side with something in the WAS application; perhaps change some parameters, and then run the report again. This is a useful feature of Alpha's non-WAS reports, which open in a new print-preview window.

Lenny Forziati
10-08-2004, 10:00 AM
Steve, this could actually be quite easy to accomplish then because you don't need the redirect to open the page. Assuming you've created your app similar to the Web App Demo page (http://was.alphasoftware.com/web_applications_demo/default/Orders_wItems.a5w), all you need to do is change your hyperlink for the report. Your
"a href="report.a5w?invnum=123">
would become something like
"a onClick="window.open('report.a5w?invnum=123','new_window_for_reports')>


10-08-2004, 06:01 PM
Lenny's example is for a link, not a response.redirect(). If you want to use a link, then it's a snap to open a new window without using javascript. Just follow the examples of how links are created for grids, which allow you to open links in new target pages. I use code something like this at the bottom of a page:

"%a5 link=""a href=\"PrintOptions.a5w?recno="+\
recno+"\" target=\"_blank\""Print Options"/a""
? ""br""+link

which opens the PrintOptions.a5w page in a new browser window.