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.
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
Most browsers support the window.console
object from the Console API:
console.log("Hello world");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With