Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2003, 03:16 AM
Registered User
 
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Closing window without prompt

Hi,
 I'm having the following tasks tough to implement in .NET. Please help me to sort them out.

1.How to store an object in java script into Session variable at the client side?

2.How to pass the object in java script to server?

3.How can handle the object/variable in javascript from server.

4. How can i close the window without prompt in javascript?

Thankyou.
 
Old June 5th, 2003, 07:45 AM
Authorized User
 
Join Date: Jun 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tgopal
Default

i think the last three issues are not possible.because from server we can't able to access the javascript objects/variable and viceversa.if you are trying to close parent window from child window then it prompts , for this issue i searched in lot of sites but all of them told that it is not possible.For the first issue we can able to assign the variable to javascript session variable.but it may not work in other browsers except IE.
 
Old June 6th, 2003, 07:54 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to james_sellwood
Default

To close a browser window in Javascript you use the:

Code:
window.close()
method. This will close any window that you created (as a web designer) usually with the

Code:
window.open("","","")
method. If the browser window was opened by the user via a shortcut or icon on their machine (say on their desktop) then the browser will always prompt the user to confirm whether or not to close the browser.

--------------------
:) James Sellwood :)
--------------------
 
Old June 6th, 2003, 11:42 AM
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to oreolla
Default

Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
    window.opener = top;
    window.close();
}
 
Old June 9th, 2003, 10:40 AM
Authorized User
 
Join Date: Jun 2003
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

Very interesting trick to close a window without a prompt. I'll try it. (I'll also bet that the browser developers will fix this loophole in the future.)

Anyway, back to the original post:

1. Technically, you can't. On the client side, there is no access to session state or to anything on the server. See answer to #2.
2. (How is this different from #1?) The only way to pass values back to the server is via an HTML form element. So, you might try to use <INPUT TYPE="HIDDEN" ID="myvalue" runat="server" .../> and in your script you set the value of the "myvalue" element to whatever you want to pass back to the server. On the server, in the Page_Load handler (or wherever you like) you can then access the myvalue.Value property and get the value.
3. Not sure what you mean by this. I think I have answered it in #2.
4. See other replies.




-Van
(Old dog learning new tricks...)
 
Old June 25th, 2003, 06:53 AM
Authorized User
 
Join Date: Jun 2003
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by oreolla
 Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
    window.opener = top;
    window.close();
}
this trick works great with ie5.5 and above...but not with the version of internet explorer which is included in win98 (i guess that's ie4??). Does anybody have a clue how to get this done on a win98 machine?

thnks in advance,

Harold
 
Old July 31st, 2003, 12:19 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Haroldd, Harold (Harry) here;
Thanks a lot!
Works great;
I was stuck on this one all morning trying to get rid of that prompt.
I needed to open my main page with control over chrome so I created a script page that does this. When I tried to automatically close said page I was surprised to see I could not do it transparently.
It just made the whole process look ... cheezey.
Thanks again;
Harry G.

p.s. this is first post here so if I've screwed thing up a bit please forgive.

Quote:
quote:Originally posted by oreolla
 Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
    window.opener = top;
    window.close();
}
:D

jack-o-all master(?)
 
Old August 6th, 2003, 02:27 PM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to troyologist
Default

This sacript was orginally made by me and its FREE.

<script language="JavaScript">
var bloodythief = 5;

{
    window.setTimeout("window.close()",bloodythief*100 0);
    window.opener = top;
}


</script>

:D bloody_thief® and the liQuid_iMager®,
:D making things a lil bit simple.

 
Old February 5th, 2005, 02:33 PM
Registered User
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by oreolla
 Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
    window.opener = top;
    window.close();
}
Hi,

It is simply excellent. It works excellent with only one window open. Now I have a problem more here. I want to open another window first and then close the main window. When I try to close the main window ONLY, it is closing my child window also, which I don't want. Is there any way to keep my child window open and close only main window??

Thanks in advance,

- Copy-Paster (Not a programmer)
 
Old February 6th, 2005, 12:05 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Check my blog :: http://vadivel.blogspot.com/2004/02/...nt-window.html

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 01:18 AM
Closing page without prompt in IE7 gp_mk ASP.NET 1.0 and 1.1 Professional 2 November 22nd, 2006 10:29 AM
Can command prompt show in window forms? g0dchild_85 C# 0 June 26th, 2006 09:04 PM
Closing window Netscape r_ganesh76 Javascript 1 November 22nd, 2004 11:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.