如何在浏览器中从未格式化的数据创建表格?
我有一个生成的日志文件,记录实用程序访问的时间戳。日志看起来与此类似,
Fri May 27 12:43:48 PDT 2011 user1 command1 1 2 3
Fri May 27 12:43:50 PDT 2011 user1 command2 abcdef 12 11
Fri May 27 12:44:00 PDT 2011 user1 command3
Fri May 27 12:45:12 PDT 2011 user1 command4
我通过浏览器访问此文件来检查活动。
由于该文件是文本文件,因此不太容易阅读。
是否可以(使用Javascript?)在浏览器中加载后修改文件,以便时间戳,用户名和命令以三个方式显示表的列,原始文件不受影响?
如果重要的话,我使用的是 Chrome 12,因此任何特定于该浏览器的解决方案也都可以使用。
I have a log file that is generated and records timestamps of utility access. The log looks similar to this
Fri May 27 12:43:48 PDT 2011 user1 command1 1 2 3
Fri May 27 12:43:50 PDT 2011 user1 command2 abcdef 12 11
Fri May 27 12:44:00 PDT 2011 user1 command3
Fri May 27 12:45:12 PDT 2011 user1 command4
I access this file through my browser to check the activity.
Since the file is a text file, is is not very easy to read.
Is it possible (using Javascript?) to modify the file after loading in the browser, so that timestamp, username and command are displayed in three columns of a table, and the original file is not affected?
If it matters, I am using Chrome 12, so any solution specific to the browser will also work.
您可以编写一个 JavaScriptlet(浏览器栏中的 javascript: URL 快捷方式)来执行以下操作:
因此,只需将所有内容压缩到一行并将快捷方式保存为“
javascript:[此处的代码]
“它应该可以工作。理论上来说。我没试过。You could write a JavaScriptlet (a javascript: URL shortcut in your browser bar) that does something like this:
So just compress that all onto a single line and save your shortcut as "
javascript:[code here]
" and it should work. Theoretically. I haven't tried it.