Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we create log files using javascript

Instead fo displaying in alert box I want to direct my output from javascript to a log file. Is there any method for doing it. If so please explain it with an example.

like image 836
user1275375 Avatar asked Mar 26 '12 05:03

user1275375


2 Answers

Yes, using the google chrome browser hit the f12 key, and click on the console button. Then use

console.log(your code);

you can log objects, arrays, strings ,variables. Much more useful than alerts.

Also in firefox the firebug plugin is quite useful. Has similar functionality, and adds the inspect element function that google chrome has built in.

EDIT: Ok, based on your comment, you cannot just write to their file system. The browser will not let you. If you want something unobtrusive try something like a classy modal window or overlay, something that is optional for the user to interact with rather than the annoying alerts and confirms. You could even add something like this http://davidwalsh.name/dw-content/top-bar-opacity.php

like image 185
user1289347 Avatar answered Sep 22 '22 18:09

user1289347


Most browsers support the window.console object from the Console API:

console.log("Hello world");
like image 25
Greg Hewgill Avatar answered Sep 24 '22 18:09

Greg Hewgill