Forum Moderators: open

Message Too Old, No Replies

session lost on window.open

IIS session lost when using window.open from scriptlet to open new window

         

broniusm

11:47 pm on Oct 22, 2003 (gmt 0)

10+ Year Member



A while back, I most frustratedly posted about a weird occurrence: I use window.open throughout my web app, and ne'er an err do I incurr. Using a scriptlet [msdn.microsoft.com] to instantiate a db driven help system, however, I found that window.open opened a new window as a new session! (In turn, I had to log in again, didn't have access to the "same" cookie, etc).

5 months later, and having brushed this aside as "just one of those things," a solution hit me: window.parent.open(). Apparently, the embedded object (scriptlet) itself is in and of its own session. Interestingly, however, this session can "talk to" other sessions via window.parent and such, as necessary.

Just thought I'd throw that out there for you gluttons for IE javascript and IIS woes.

broniusm

9:06 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



By the way, the post I'm referring to here was the thread on apparently lost IIS session variables because of a scriptlet [webmasterworld.com].

lisadi

9:09 pm on Dec 5, 2003 (gmt 0)


Hi,

I would like to know how the window.parent.open method in JavaScript worked for you.

I am in a similar situation. Currently, I am sending key values for database queries in a new window through a hidden field. Keeping this in the same session would be much better. (so you couldn't do a view source and view the hidden field)

When you say 'parent', is that where I put the document name?

Here's how I currently have this set up. How should this be changed?

<script language="JavaScript">
<!--
function myOpenWindow()
{
myWindowHandle = window.open('about:blank','Print Comments','width=800,height=600');
}
//-->
</script>

.
.
.

<form action="print_comments.asp" target="_blank" method="post" name="hidden_print" onSubmit="myOpenWindow()">

<input type="hidden" value=<%= Session("keyed_ssn") %> name="keyed_ssn_h">
<input type="hidden" value=<%= Session("rev_id") %> name="rev_id_h">

<input type="submit" value="Print Comments" name="enter" >
</form>

Thanks!
Lisa

broniusm

9:20 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



Lisa-
Looks to me like you may not *need* window.parent.open. window.**** refers to any variable/function in a given document, and parent is the window containing the current document. (others are .self, .opener..)

ex. In an iframe (or scriplet as with my issue), window and window.self is the iframe, and window.parent is the window containing the iframe.

Is your document within an iframe?

broniusm

9:23 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



Wait, I take that back.
The issue at-hand here is that you're submitting to a javascript function which invokes a call to a new window. You're not losing any sessions, you're just not receiving the GET/POST. Instead, put as your action a filename, and add a target to your form:

ex:


<form action="printdoc.asp" target="winDocPrint">
...
</form>

broniusm

9:30 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



Since I'm typing, let me post the most elegant solution:

<script>
function openwin() {
window.open("about:blank", "winDocPrint", "..size,etc");
}
</script>

<form action="printdoc.asp" target="winDocPrint" onsubmit="openwin">
...
</form>

Notice that winDocPrint refers to and corresponds with the name of the window you've opened on submit.

That should do something like what you want: open a new window to a certain size and submit a form to it.