03. august 2001 - 00:38Der er
6 kommentarer og 1 løsning
Brug for kode til en simpel \"Online-Now\" Hitcounter (der virker)
Jeg har forsøgt at få en counter, som viser hvor mange aktive brugere der er på hjemmesiden \"lige nu\". Jeg har forsøgt at skrive min egen, men den virker ikke hos Brinkster.com. Hvis du svarer så tjek lige at det ikke er noget du har kopieret fra Beginning Active Server Pages 3.0 fra wrox kapitel 8 - det har jeg prøvet og det virker heller ikke. Koden må også gerne indeholde en total counter.
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
prøv og kig på denne her: Først en global.asa, den indeholder en del flere funktioner end det du spørger om, men dem kan du bare fjerne !
//<script language=JavaScript runat=server>
// ============================================ // this function is called when the first user visits the page after the server // has been rebooted. also called when this file is changed. // ============================================ function Application_OnStart ( ) { // you must lock the global Application object // when writing to it - ok to read without lock Application.Lock ( );
// number of users currently on the site Application ( \'ActiveUsers\' ) = 0; // number of users on the site today Application ( \'UsersToday\' ) = 0; // number of pages viewed today Application ( \'PagesToday\' ) = 0; // has the count been restarted today? Application ( \'NewToday\' ) = 1; // number of headers viewed ever Application ( \'HeadersViewed\' ) = 0; // number of footers viewed ever Application ( \'FootersViewed\' ) = 0; // initialize new stuff in utils/Init.asp Application ( \'BrandNewDay\' ) = 1; // a list of IP addresses that have clicked an ad Application ( \'ClickFromIP\' ) = \'\'; // counters for rotating banners Application ( \'CurrentTopBanner\' ) = 0; Application ( \'CurrentSideBanner\' ) = 0; Application ( \'CurrentAffiliate\' ) = 0;
// remember todays date var d = new Date; Application ( \'Today\' ) = d.getDate ( );
Application.Unlock ( ); }
// ============================================ // this function is called when the server shuts down // ============================================ function Application_OnEnd ( ) { }
// ============================================ // this function gets called whenever a new user visits the site. note that // session variables require the client browser to accept cookies // ============================================ function Session_OnStart ( ) { // you must lock the global Application object // when writing to it - ok to read without lock Application.Lock ( );
// one more active user Application ( \'ActiveUsers\' )++;
// is it a new day? var d = new Date; var nDate = d.getDate ( );
// and say I havent restarted today Application ( \'NewToday\' ) = 0; }
Application.Unlock ( ); }
// ============================================ // this function gets called after a user session times out - by default // after 20 minutes. or you can call Session.Abandon ( ) // ============================================ function Session_OnEnd ( ) { // you must lock the global Application object // when writing to it - ok to read without lock Application.Lock ( );
// one less active user Application ( \'ActiveUsers\' )--;
Application.Unlock ( ); } </script> //
Så en \"vis brugere online\" ialt brugere og sider ialt, der hvor den skal placeres ! // lock the application so I can increment page counter Application.Lock ( ); Application ( \'PagesToday\' )++; Application.Unlock ( );
// display the data var nUsers = Application ( \'ActiveUsers\' ) - 0; var nUsersToday = Application ( \'UsersToday\' ) - 0; var nPagesToday = Application ( \'PagesToday\' ) - 0; var bRebootToday = Application ( \'NewToday\' ) - 0;
Jeg takker for hjælpen allesammen, og især florint og nuno !
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.