Welcome to WebmasterWorld Guest from

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

Log files with Javascript.

3:58 pm on Nov 25, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 22, 2004
posts: 71
votes: 0

I saw this on this thread [webmasterworld.com...]

$uri = "http://www.mysite.com" . $_SERVER['REQUEST_URI'];
$dtime = date('r');

$line = "$unixtime;$dtime;$ip;$uri;$ref";

$f = fopen("log.log", "a");

@fwrite($f, $line . "\n");

and I've got this working in a fuction in an includes file but how could i do the same with javascript? so I could enter a piece of javascript. in each file?

Thank you.

9:24 pm on Nov 30, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Mar 26, 2003
votes: 0

You can't write to the server with javascript. At best, you can use Javascript to submit data to a server side script (using PHP, ASP, or some other language) and write to the filesystem in that language. But that goes beyond your basic logging. You should restrict Javascript logging to capturing data in the browser that the server can't catch on it's own, and for use with third party solutions (like Google Analytics). Just use a server side script or your server logs.

If you can't see your log and you can't use server side scripting, change your web host.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members