JoshWithrow Posted June 4, 2003 Posted June 4, 2003 I need to know how to fire a piece of code when either: 1. The user leaves the page. 2. The user closes the browser. Any idea's? Quote
*Gurus* Derek Stone Posted June 4, 2003 *Gurus* Posted June 4, 2003 This can only be done using a client-side scripting language, such as JavaScript. This can not be done directly from ASP.NET. <body onunload="java[b][/b]script:alert('This page is unloading.')"> Quote Posting Guidelines
JoshWithrow Posted June 4, 2003 Author Posted June 4, 2003 Okay... time to get explanatory. I'm attempting to include a section on my website that displays users currently logged on, and the number of guests that are on the site. I have a DB setup with the appropriate fields, and have no problem populating them (adding a guest upon opening the site, adding a user that's logged in to my list), but rather unpopulating/updating them upon the user leaving. I've seen this done in many PHP sites, and some .NET, but don't know how to do it myself. Should this be a global.asax thing? I've yet to do a project with global.asax, and this is probably a good time to start. Please let me know. the website is http://www.JoshAndBrandi.com/NEW/ feel free to take a look and provide any other constructive criticism. BTW, this site is going to be 100% text/css - NO PICTURES. I'm attempting to provide a VERY speedy product for people that are even on dial-up. Thanks!!! Quote
*Gurus* Derek Stone Posted June 4, 2003 *Gurus* Posted June 4, 2003 You're going about this the wrong way. Instead of looking for an event (the web is a stateless environment, no matter how much one would like it otherwise) that signifies a user leaving, keep track of when they have been there. Each time a user visits a page update a "LastActivity" field in your database with the current date and time. Then, on your "who's online" page, query for those users who have been active within the last 15 minutes or so. Quote Posting Guidelines
JoshWithrow Posted June 4, 2003 Author Posted June 4, 2003 ahhhH!!!! nice idea!!! I never thoughta that!!! :duh: Quote
*Gurus* Derek Stone Posted June 4, 2003 *Gurus* Posted June 4, 2003 I'm attempting to provide a VERY speedy productYou might want to get rid of all your table elements, in favor of layers, remove the useless font tags you have in there and transfer the majority of your tag attributes to their CSS equivalents. Quote Posting Guidelines
JoshWithrow Posted June 4, 2003 Author Posted June 4, 2003 I did move mostly everything except the header to CSS, but i'll look into the layers. Thanks!!! I'll be adding some color changes, too. Quote
bizzydint Posted June 5, 2003 Posted June 5, 2003 are layers really more efficient than tables? and do layers work properly on non-IE browsers?? (Probably wrong forum for these kinds of questions, but they seemed relevant to the thread....) Quote Grant me the serenity to accept the things I cannot change, the courage to change the things I cannot accept and the wisdom to hide the bodies of those people I had to kill today cos they pi**ed me off.
JoshWithrow Posted June 5, 2003 Author Posted June 5, 2003 Actually, After looking into Layers, I can't say that they're necessarily any more efficient than tables. I know tables take time to render, but c'mon - what doesn't? And for the end result I want, I don't see an efficient way to implement layers. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.