Logging out when you close the browser

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
lloydie-t
Forum Commoner
Posts: 88
Joined: Thu Jun 27, 2002 3:41 am
Location: UK

Logging out when you close the browser

Post by lloydie-t »

I have recently been working with a system that you can use a browser to configure it. What interested me is that when you attempted to close the browser down a new window would open asking wether you wanted to logout og the programming session. How is that done? Be easy with me I know nothing of JS.
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

use the event handler onUnload to open a new window or use alert().
lloydie-t
Forum Commoner
Posts: 88
Joined: Thu Jun 27, 2002 3:41 am
Location: UK

Post by lloydie-t »

Nincha, belated thanks. I have managed to get it to work in a fashion, but I need to make it a little neater by also resizing the window it will open. I have tried the follwing but no joy.

Code: Select all

<html> 
<head> 
<script script language="JavaScript"> 
function LogoutSessionUser() 
&#123; window.open("http://www.touch.com/support/desk/sesslogout.php",
'toolbar=no,location=no,directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,width=200,height=100')
&#125; 
</script> 
</head> 

<body onUnload=LogoutSessionUser()> 

</body> 
</html>
Can anyone help me?
qman
Forum Newbie
Posts: 2
Joined: Tue Jun 10, 2003 6:30 pm

Try this

Post by qman »

Hey there. Try this in the <body>

<body onUnload="LogoutSessionUser()">

See if the quotes work for ya :wink:
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

a little more

Post by phpScott »

exactly what qman said but i find that it is sometimes neccessary to put a semi colon at the end or the onUnload event like so

Code: Select all

<body onUnload="LogoutSessionUser();">
phpScott
Post Reply