 |
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
|
|
|

June 5th, 2003, 03:16 AM
|
Registered User
|
|
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

June 5th, 2003, 07:45 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

June 6th, 2003, 07:54 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
|
|
To close a browser window in Javascript you use the:
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 :)
--------------------
|

June 6th, 2003, 11:42 AM
|
Registered User
|
|
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, not always ;)
Here is a trick:
Code:
function tricky_win_close() {
window.opener = top;
window.close();
}
|

June 9th, 2003, 10:40 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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...)
|

June 25th, 2003, 06:53 AM
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 31st, 2003, 12:19 PM
|
Registered User
|
|
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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(?)
|

August 6th, 2003, 02:27 PM
|
Registered User
|
|
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

February 5th, 2005, 02:33 PM
|
Registered User
|
|
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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)
|

February 6th, 2005, 12:05 AM
|
Friend of Wrox
|
|
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|
 |