By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

not sure why close window function not working

P: n/a
Hi I have 2 functions in java script, one opens a second window-this works,
the other is supposed to close this second window, does not seem to be
working. Just wondering if anyone had any ideas.
Here is the code,
the functions are
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
below is how I am trying to call the functions,
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</form>
thanks,
--
Paul G
Software engineer.
Nov 18 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
the code is ok, but if the open button click fires a postback, or a postback
is done before you call close it will not work, as you will have lost the
window handle.

-- bruce (sqlwork.com)

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
| Hi I have 2 functions in java script, one opens a second window-this
works,
| the other is supposed to close this second window, does not seem to be
| working. Just wondering if anyone had any ideas.
| Here is the code,
| the functions are
| <script language="javascript">
| function openwin(){
| win_usr=window.open ("control_numinfo.aspx")
| }
| function closewin(){
| win_usr.close();
| }
| </script>
| below is how I am trying to call the functions,
| <script language="javascript" event="onclick()" for="btn_user">
| openwin();
| </script>
| <script language="javascript" event="onclick()" for="btn_clear">
| closewin();
| </script>
| </form>
| thanks,
| --
| Paul G
| Software engineer.
Nov 18 '05 #2

P: n/a
I've written sample code and tested it in IE6, and it works.
<html>
<head>
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</head>
<body>
<form runat=server>
<input id="btn_user" type="button">
<input id="btn_clear" type="button">
</form>
</body>
</html>

However it's not going to be work in Mozilla based browsers such as Mozilla,
Netscape and Firefox.
For reference on how to do it, see here:
http://wdvl.com/Authoring/JavaScript...turing_ns.html

Also, make sure your button do NOT have "runat = 'server'" attribute.

"Paul" <Pa**@discussions.microsoft.com> bl
news:0A**********************************@microsof t.com g...
Hi I have 2 functions in java script, one opens a second window-this works, the other is supposed to close this second window, does not seem to be
working. Just wondering if anyone had any ideas.
Here is the code,
the functions are
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
below is how I am trying to call the functions,
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</form>
thanks,
--
Paul G
Software engineer.

Nov 18 '05 #3

P: n/a
ok thanks for the information, could be that a postback is happening so
loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:
the code is ok, but if the open button click fires a postback, or a postback
is done before you call close it will not work, as you will have lost the
window handle.

-- bruce (sqlwork.com)

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
| Hi I have 2 functions in java script, one opens a second window-this
works,
| the other is supposed to close this second window, does not seem to be
| working. Just wondering if anyone had any ideas.
| Here is the code,
| the functions are
| <script language="javascript">
| function openwin(){
| win_usr=window.open ("control_numinfo.aspx")
| }
| function closewin(){
| win_usr.close();
| }
| </script>
| below is how I am trying to call the functions,
| <script language="javascript" event="onclick()" for="btn_user">
| openwin();
| </script>
| <script language="javascript" event="onclick()" for="btn_clear">
| closewin();
| </script>
| </form>
| thanks,
| --
| Paul G
| Software engineer.

Nov 18 '05 #4

P: n/a
ok thanks for the information

"Lau Lei Cheong" wrote:
I've written sample code and tested it in IE6, and it works.
<html>
<head>
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</head>
<body>
<form runat=server>
<input id="btn_user" type="button">
<input id="btn_clear" type="button">
</form>
</body>
</html>

However it's not going to be work in Mozilla based browsers such as Mozilla,
Netscape and Firefox.
For reference on how to do it, see here:
http://wdvl.com/Authoring/JavaScript...turing_ns.html

Also, make sure your button do NOT have "runat = 'server'" attribute.

"Paul" <Pa**@discussions.microsoft.com> ¦b¶l¥ó
news:0A**********************************@microsof t.com ¤¤¼¶¼g...
Hi I have 2 functions in java script, one opens a second window-this

works,
the other is supposed to close this second window, does not seem to be
working. Just wondering if anyone had any ideas.
Here is the code,
the functions are
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
below is how I am trying to call the functions,
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</form>
thanks,
--
Paul G
Software engineer.


Nov 18 '05 #5

P: n/a
Hi I tried the code and it worked but when I use .NET to add the buttons and
take out the run at server attribute the button does not even show up on the
form.
See below

<asp:Button id="btn_user" style="Z-INDEX: 101; LEFT: 152px; POSITION:
absolute; TOP: 80px" Text="Open" CausesValidation="False"></asp:Button>
Just wondering if there is another attribute I should add in place of the
runat server.
"Lau Lei Cheong" wrote:
I've written sample code and tested it in IE6, and it works.
<html>
<head>
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</head>
<body>
<form runat=server>
<input id="btn_user" type="button">
<input id="btn_clear" type="button">
</form>
</body>
</html>

However it's not going to be work in Mozilla based browsers such as Mozilla,
Netscape and Firefox.
For reference on how to do it, see here:
http://wdvl.com/Authoring/JavaScript...turing_ns.html

Also, make sure your button do NOT have "runat = 'server'" attribute.

"Paul" <Pa**@discussions.microsoft.com> ¦b¶l¥ó
news:0A**********************************@microsof t.com ¤¤¼¶¼g...
Hi I have 2 functions in java script, one opens a second window-this

works,
the other is supposed to close this second window, does not seem to be
working. Just wondering if anyone had any ideas.
Here is the code,
the functions are
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
below is how I am trying to call the functions,
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</form>
thanks,
--
Paul G
Software engineer.


Nov 18 '05 #6

P: n/a
A PostBack is certainly going to lose the handle. You realize that each Page
instance is occurring in a vacuum, don't you? When the page reloads into the
browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
ok thanks for the information, could be that a postback is happening so
loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:
the code is ok, but if the open button click fires a postback, or a postback is done before you call close it will not work, as you will have lost the window handle.

-- bruce (sqlwork.com)

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
| Hi I have 2 functions in java script, one opens a second window-this
works,
| the other is supposed to close this second window, does not seem to be
| working. Just wondering if anyone had any ideas.
| Here is the code,
| the functions are
| <script language="javascript">
| function openwin(){
| win_usr=window.open ("control_numinfo.aspx")
| }
| function closewin(){
| win_usr.close();
| }
| </script>
| below is how I am trying to call the functions,
| <script language="javascript" event="onclick()" for="btn_user">
| openwin();
| </script>
| <script language="javascript" event="onclick()" for="btn_clear">
| closewin();
| </script>
| </form>
| thanks,
| --
| Paul G
| Software engineer.

Nov 18 '05 #7

P: n/a
Hi thanks for the response. Yes everything is new as you mentioned. I was
able to get it working by using the <input statement for the button that
opens the child window, does not cause a post back. I have another window
that has a column of buttons in a data grid and when these buttons are
selected, it opens a child window. Guess in this case it is posting back to
the server so will have to some how save off the handle name and then
retreive it and use it in the onunload event of the parent window in the body
tag, so when the parent window navigates away the child window if left open
will be closed.

"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each Page
instance is occurring in a vacuum, don't you? When the page reloads into the
browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
ok thanks for the information, could be that a postback is happening so
loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:
the code is ok, but if the open button click fires a postback, or a postback is done before you call close it will not work, as you will have lost the window handle.

-- bruce (sqlwork.com)

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
| Hi I have 2 functions in java script, one opens a second window-this
works,
| the other is supposed to close this second window, does not seem to be
| working. Just wondering if anyone had any ideas.
| Here is the code,
| the functions are
| <script language="javascript">
| function openwin(){
| win_usr=window.open ("control_numinfo.aspx")
| }
| function closewin(){
| win_usr.close();
| }
| </script>
| below is how I am trying to call the functions,
| <script language="javascript" event="onclick()" for="btn_user">
| openwin();
| </script>
| <script language="javascript" event="onclick()" for="btn_clear">
| closewin();
| </script>
| </form>
| thanks,
| --
| Paul G
| Software engineer.


Nov 18 '05 #8

P: n/a
Just had an additional question, below is what I have that opens a child
window(created by .NET for a hyperlink data column grid),
is there a way to assign a handle to this so I can build a close function
and call it when the parent window unloads?
<asp:HyperLinkColumn Text="View" Target="_blank"
DataNavigateUrlField="Data_Item_ID"
DataNavigateUrlFormatString="child.aspx?i_Data_Ite m_ID={0}"

thanks Paul.
"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each Page
instance is occurring in a vacuum, don't you? When the page reloads into the
browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
ok thanks for the information, could be that a postback is happening so
loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:
the code is ok, but if the open button click fires a postback, or a postback is done before you call close it will not work, as you will have lost the window handle.

-- bruce (sqlwork.com)

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
| Hi I have 2 functions in java script, one opens a second window-this
works,
| the other is supposed to close this second window, does not seem to be
| working. Just wondering if anyone had any ideas.
| Here is the code,
| the functions are
| <script language="javascript">
| function openwin(){
| win_usr=window.open ("control_numinfo.aspx")
| }
| function closewin(){
| win_usr.close();
| }
| </script>
| below is how I am trying to call the functions,
| <script language="javascript" event="onclick()" for="btn_user">
| openwin();
| </script>
| <script language="javascript" event="onclick()" for="btn_clear">
| closewin();
| </script>
| </form>
| thanks,
| --
| Paul G
| Software engineer.


Nov 18 '05 #9

P: n/a
Afraid not, Paul. The problem isn't the name, it's what it points to, which
is gone after the PostBack. It's an actual in-memory handle to a browser
window. There is simply no way to persist it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com...
Hi thanks for the response. Yes everything is new as you mentioned. I was
able to get it working by using the <input statement for the button that
opens the child window, does not cause a post back. I have another window that has a column of buttons in a data grid and when these buttons are
selected, it opens a child window. Guess in this case it is posting back to the server so will have to some how save off the handle name and then
retreive it and use it in the onunload event of the parent window in the body tag, so when the parent window navigates away the child window if left open will be closed.

"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each Page instance is occurring in a vacuum, don't you? When the page reloads into the browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
ok thanks for the information, could be that a postback is happening so loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:

> the code is ok, but if the open button click fires a postback, or a

postback
> is done before you call close it will not work, as you will have lost
the
> window handle.
>
> -- bruce (sqlwork.com)
>
> "Paul" <Pa**@discussions.microsoft.com> wrote in message
> news:0A**********************************@microsof t.com...
> | Hi I have 2 functions in java script, one opens a second

window-this > works,
> | the other is supposed to close this second window, does not seem to be > | working. Just wondering if anyone had any ideas.
> | Here is the code,
> | the functions are
> | <script language="javascript">
> | function openwin(){
> | win_usr=window.open ("control_numinfo.aspx")
> | }
> | function closewin(){
> | win_usr.close();
> | }
> | </script>
> | below is how I am trying to call the functions,
> | <script language="javascript" event="onclick()" for="btn_user">
> | openwin();
> | </script>
> | <script language="javascript" event="onclick()" for="btn_clear">
> | closewin();
> | </script>
> | </form>
> | thanks,
> | --
> | Paul G
> | Software engineer.
>
>
>


Nov 18 '05 #10

P: n/a
Hi Paul,

Only the JavaScript window.open() method returns a handle to a window.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Just had an additional question, below is what I have that opens a child
window(created by .NET for a hyperlink data column grid),
is there a way to assign a handle to this so I can build a close function
and call it when the parent window unloads?
<asp:HyperLinkColumn Text="View" Target="_blank"
DataNavigateUrlField="Data_Item_ID"
DataNavigateUrlFormatString="child.aspx?i_Data_Ite m_ID={0}"

thanks Paul.
"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each Page instance is occurring in a vacuum, don't you? When the page reloads into the browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
ok thanks for the information, could be that a postback is happening so loosing the handle. Guess one could save the handle in a session
variable,not quite sure how this would work.

"bruce barker" wrote:

> the code is ok, but if the open button click fires a postback, or a

postback
> is done before you call close it will not work, as you will have lost
the
> window handle.
>
> -- bruce (sqlwork.com)
>
> "Paul" <Pa**@discussions.microsoft.com> wrote in message
> news:0A**********************************@microsof t.com...
> | Hi I have 2 functions in java script, one opens a second

window-this > works,
> | the other is supposed to close this second window, does not seem to be > | working. Just wondering if anyone had any ideas.
> | Here is the code,
> | the functions are
> | <script language="javascript">
> | function openwin(){
> | win_usr=window.open ("control_numinfo.aspx")
> | }
> | function closewin(){
> | win_usr.close();
> | }
> | </script>
> | below is how I am trying to call the functions,
> | <script language="javascript" event="onclick()" for="btn_user">
> | openwin();
> | </script>
> | <script language="javascript" event="onclick()" for="btn_clear">
> | closewin();
> | </script>
> | </form>
> | thanks,
> | --
> | Paul G
> | Software engineer.
>
>
>


Nov 18 '05 #11

P: n/a
ok thanks for the information.

"Kevin Spencer" wrote:
Afraid not, Paul. The problem isn't the name, it's what it points to, which
is gone after the PostBack. It's an actual in-memory handle to a browser
window. There is simply no way to persist it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com...
Hi thanks for the response. Yes everything is new as you mentioned. I was
able to get it working by using the <input statement for the button that
opens the child window, does not cause a post back. I have another

window
that has a column of buttons in a data grid and when these buttons are
selected, it opens a child window. Guess in this case it is posting back

to
the server so will have to some how save off the handle name and then
retreive it and use it in the onunload event of the parent window in the

body
tag, so when the parent window navigates away the child window if left

open
will be closed.

"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each Page instance is occurring in a vacuum, don't you? When the page reloads into the browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
> ok thanks for the information, could be that a postback is happening so > loosing the handle. Guess one could save the handle in a session
> variable,not quite sure how this would work.
>
> "bruce barker" wrote:
>
> > the code is ok, but if the open button click fires a postback, or a
postback
> > is done before you call close it will not work, as you will have lost the
> > window handle.
> >
> > -- bruce (sqlwork.com)
> >
> > "Paul" <Pa**@discussions.microsoft.com> wrote in message
> > news:0A**********************************@microsof t.com...
> > | Hi I have 2 functions in java script, one opens a second window-this > > works,
> > | the other is supposed to close this second window, does not seem to be > > | working. Just wondering if anyone had any ideas.
> > | Here is the code,
> > | the functions are
> > | <script language="javascript">
> > | function openwin(){
> > | win_usr=window.open ("control_numinfo.aspx")
> > | }
> > | function closewin(){
> > | win_usr.close();
> > | }
> > | </script>
> > | below is how I am trying to call the functions,
> > | <script language="javascript" event="onclick()" for="btn_user">
> > | openwin();
> > | </script>
> > | <script language="javascript" event="onclick()" for="btn_clear">
> > | closewin();
> > | </script>
> > | </form>
> > | thanks,
> > | --
> > | Paul G
> > | Software engineer.
> >
> >
> >


Nov 18 '05 #12

P: n/a
It is because ASP.NET buttons are "always" run at server.
If they're not placed inside <form runat="server">, you'll see a parser
error tell you to do so.
Also, using <asp:> controls will introduce one more postback to "create" the
control it'll cause slower performance, that's why people here trend to
advise others use plain HTML controls instead.

In this case you should use <input type="button/submit/image"> instead.

"Paul" <Pa**@discussions.microsoft.com> bl
news:B5**********************************@microsof t.com g...
Hi I tried the code and it worked but when I use .NET to add the buttons and take out the run at server attribute the button does not even show up on the form.
See below

<asp:Button id="btn_user" style="Z-INDEX: 101; LEFT: 152px; POSITION:
absolute; TOP: 80px" Text="Open" CausesValidation="False"></asp:Button>
Just wondering if there is another attribute I should add in place of the
runat server.
"Lau Lei Cheong" wrote:
I've written sample code and tested it in IE6, and it works.
<html>
<head>
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</head>
<body>
<form runat=server>
<input id="btn_user" type="button">
<input id="btn_clear" type="button">
</form>
</body>
</html>

However it's not going to be work in Mozilla based browsers such as Mozilla, Netscape and Firefox.
For reference on how to do it, see here:
http://wdvl.com/Authoring/JavaScript...turing_ns.html

Also, make sure your button do NOT have "runat = 'server'" attribute.

"Paul" <Pa**@discussions.microsoft.com> |b?lDo
news:0A**********************************@microsof t.com ?????g...
Hi I have 2 functions in java script, one opens a second window-this

works,
the other is supposed to close this second window, does not seem to be
working. Just wondering if anyone had any ideas.
Here is the code,
the functions are
<script language="javascript">
function openwin(){
win_usr=window.open ("control_numinfo.aspx")
}
function closewin(){
win_usr.close();
}
</script>
below is how I am trying to call the functions,
<script language="javascript" event="onclick()" for="btn_user">
openwin();
</script>
<script language="javascript" event="onclick()" for="btn_clear">
closewin();
</script>
</form>
thanks,
--
Paul G
Software engineer.


Nov 18 '05 #13

P: n/a
Yes. So the workaround would be to supply
"javascript:fhandle=windo.open('url');". :)

"Kevin Spencer" <ks******@takempis.com> bl
news:%2****************@TK2MSFTNGP15.phx.gbl g...
Hi Paul,

Only the JavaScript window.open() method returns a handle to a window.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Just had an additional question, below is what I have that opens a child
window(created by .NET for a hyperlink data column grid),
is there a way to assign a handle to this so I can build a close function
and call it when the parent window unloads?
<asp:HyperLinkColumn Text="View" Target="_blank"
DataNavigateUrlField="Data_Item_ID"
DataNavigateUrlFormatString="child.aspx?i_Data_Ite m_ID={0}"

thanks Paul.
"Kevin Spencer" wrote:
A PostBack is certainly going to lose the handle. You realize that each
Page instance is occurring in a vacuum, don't you? When the page reloads
into
the browser, everything is new.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.com...
> ok thanks for the information, could be that a postback is happening so > loosing the handle. Guess one could save the handle in a session
> variable,not quite sure how this would work.
>
> "bruce barker" wrote:
>
> > the code is ok, but if the open button click fires a postback, or
a postback
> > is done before you call close it will not work, as you will have

lost the
> > window handle.
> >
> > -- bruce (sqlwork.com)
> >
> > "Paul" <Pa**@discussions.microsoft.com> wrote in message
> > news:0A**********************************@microsof t.com...
> > | Hi I have 2 functions in java script, one opens a second window-this > > works,
> > | the other is supposed to close this second window, does not seem to be > > | working. Just wondering if anyone had any ideas.
> > | Here is the code,
> > | the functions are
> > | <script language="javascript">
> > | function openwin(){
> > | win_usr=window.open ("control_numinfo.aspx")
> > | }
> > | function closewin(){
> > | win_usr.close();
> > | }
> > | </script>
> > | below is how I am trying to call the functions,
> > | <script language="javascript" event="onclick()" for="btn_user">
> > | openwin();
> > | </script>
> > | <script language="javascript" event="onclick()" for="btn_clear">
> > | closewin();
> > | </script>
> > | </form>
> > | thanks,
> > | --
> > | Paul G
> > | Software engineer.
> >
> >
> >


Nov 18 '05 #14

P: n/a
thanks for the information,will give it a try.
"Lau Lei Cheong" wrote:
Yes. So the workaround would be to supply
"javascript:fhandle=windo.open('url');". :)

"Kevin Spencer" <ks******@takempis.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP15.phx.gbl ¤¤¼¶¼g...
Hi Paul,

Only the JavaScript window.open() method returns a handle to a window.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
Just had an additional question, below is what I have that opens a child
window(created by .NET for a hyperlink data column grid),
is there a way to assign a handle to this so I can build a close function and call it when the parent window unloads?
<asp:HyperLinkColumn Text="View" Target="_blank"
DataNavigateUrlField="Data_Item_ID"
DataNavigateUrlFormatString="child.aspx?i_Data_Ite m_ID={0}"

thanks Paul.
"Kevin Spencer" wrote:

> A PostBack is certainly going to lose the handle. You realize that each
Page
> instance is occurring in a vacuum, don't you? When the page reloads

into
the
> browser, everything is new.
>
> --
> HTH,
> Kevin Spencer
> ..Net Developer
> Microsoft MVP
> Neither a follower
> nor a lender be.
>
> "Paul" <Pa**@discussions.microsoft.com> wrote in message
> news:21**********************************@microsof t.com...
> > ok thanks for the information, could be that a postback is happening

so
> > loosing the handle. Guess one could save the handle in a session
> > variable,not quite sure how this would work.
> >
> > "bruce barker" wrote:
> >
> > > the code is ok, but if the open button click fires a postback, or

a > postback
> > > is done before you call close it will not work, as you will have

lost
> the
> > > window handle.
> > >
> > > -- bruce (sqlwork.com)
> > >
> > > "Paul" <Pa**@discussions.microsoft.com> wrote in message
> > > news:0A**********************************@microsof t.com...
> > > | Hi I have 2 functions in java script, one opens a second

window-this
> > > works,
> > > | the other is supposed to close this second window, does not seem

to be
> > > | working. Just wondering if anyone had any ideas.
> > > | Here is the code,
> > > | the functions are
> > > | <script language="javascript">
> > > | function openwin(){
> > > | win_usr=window.open ("control_numinfo.aspx")
> > > | }
> > > | function closewin(){
> > > | win_usr.close();
> > > | }
> > > | </script>
> > > | below is how I am trying to call the functions,
> > > | <script language="javascript" event="onclick()" for="btn_user">
> > > | openwin();
> > > | </script>
> > > | <script language="javascript" event="onclick()" for="btn_clear">
> > > | closewin();
> > > | </script>
> > > | </form>
> > > | thanks,
> > > | --
> > > | Paul G
> > > | Software engineer.
> > >
> > >
> > >
>
>
>



Nov 18 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.