Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 5th, 2003, 03:16 AM
Registered User
 
Join Date: Jun 2003
Location: Pune, Maharastra, India.
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.
Reply With Quote
  #2 (permalink)  
Old June 5th, 2003, 07:45 AM
Authorized User
 
Join Date: Jun 2003
Location: , , India.
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.
Reply With Quote
  #3 (permalink)  
Old June 6th, 2003, 07:54 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
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 :)
--------------------
Reply With Quote
  #4 (permalink)  
Old June 6th, 2003, 11:42 AM
Registered User
 
Join Date: Jun 2003
Location: Cleveland, OH, USA.
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();
}
Reply With Quote
  #5 (permalink)  
Old June 9th, 2003, 10:40 AM
Authorized User
 
Join Date: Jun 2003
Location: Lexington, KY, USA.
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...)
Reply With Quote
  #6 (permalink)  
Old June 25th, 2003, 06:53 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Netherlands.
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
Reply With Quote
  #7 (permalink)  
Old July 31st, 2003, 12:19 PM
Registered User
 
Join Date: Jul 2003
Location: Waterloo, ON, Canada.
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(?)
Reply With Quote
  #8 (permalink)  
Old August 6th, 2003, 02:27 PM
Registered User
 
Join Date: Aug 2003
Location: , , .
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.

Reply With Quote
  #9 (permalink)  
Old February 5th, 2005, 01:33 PM
Registered User
 
Join Date: Feb 2005
Location: , , Panama.
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)
Reply With Quote
  #10 (permalink)  
Old February 5th, 2005, 11:05 PM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 12:18 AM
Closing page without prompt in IE7 gp_mk ASP.NET 1.0 and 1.1 Professional 2 November 22nd, 2006 09: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 10:38 AM



All times are GMT -4. The time now is 07:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.