Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 July 9th, 2004, 04:40 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Response To a Javascript - ThnX !

Hi ! :)

I need your help.

I have a log Off buttons that calls a javascript to close the browser:

Page.RegisterStartupScript("Log Off", "<script language='javascript'>javascript:window.close();</script>")

However, b/c it was not created from windows.open, I'm not able to disable or remove the confirmation.

So, is there a way to trap the response in my log off button

Or is there another way to close the browser ?

Thanks in advance !
 
Old July 9th, 2004, 04:44 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Closing the browser without confirmation:

http://snibworks.com/dhtml/article.php?id=3

Basically this set an opener to the current window, which allows you to close it without confirmation.

HTH,

Snib

<><
 
Old July 9th, 2004, 05:02 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Snib, you rock !

Please let me ask another question; it's part of what I'm doing.

If the user doesn't click on my 'Log Off' feature, and clicks on
the 'X' of the browser, is there a method or an event that gets triggered?

I know that you can include in every page:

<body onUnload="somefunction()">

But this is client-side, I need to update my db.

Thanks for your replies !
 
Old July 9th, 2004, 06:24 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I have encountered this before and usually do this: create the onUnload event handler, which calls a function to open a window which updates your database. The new window then closes.

<body onUnload="openDBWin()">
<script language=javascript>
function openDBWin()
{
 window.open('update_db.asp');
}
</script>

__update_db.asp__

<%
 'update database here
%>
<script language=javascript>
window.close();
</script>

HTH,

Snib

<><
 
Old July 9th, 2004, 08:25 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cool; just what I was thinking.

Thanks again for your inputs, really appreciate it !
 
Old July 12th, 2004, 12:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Snib.

Hope you had a good weekend.

You mentioned that you've encountered this before, so do you know that the fresh (F5) with trigger the javascript?

How did you handle this, if you don't mind answering another question?

Thanks again !
 
Old July 12th, 2004, 02:07 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I had no way to avoid this behavior.... perhaps the following code will work?

document.onkeydown=function(){handle_key;};

function handle_key()
{
 if(event.keyCode==116)return false;
}

Let me know,

Snib

<><
 
Old July 12th, 2004, 03:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Snib, thanks for trying to help.

I guess it still executes ONUNLOAD event.

I don't have any more time to work on it, but what I have is good.

Thanks again !
 
Old July 12th, 2004, 04:01 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

OOPS I messed up in the code I posted. Fixed now, try it again.

HTH,

Snib

<><
 
Old July 12th, 2004, 04:07 PM
Authorized User
 
Join Date: Jun 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

huh?





Similar Threads
Thread Thread Starter Forum Replies Last Post
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
Response.Redirect + Javascript jfergy Classic ASP Basics 2 January 17th, 2006 09:17 PM
Simply Deleting Question - ThnX ! ank2go SQL Language 2 November 16th, 2004 04:55 PM
Anchor Problem - Plz Help - ThnX ! ank2go HTML Code Clinic 6 June 30th, 2004 03:18 PM
Date Format - Truncating - Plz Help - THNX ! ank2go VB.NET 2002/2003 Basics 2 March 30th, 2004 11:26 PM





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