View Full Version : Write javascript output to file on server

06-28-2012, 12:42 AM
So I have this HTML file that tests the user's screen resolution, and plugins installed using Javascript. So when the user accesses the page it sees: (e.g.) Your current screen resolution is 1024x768 and you have the following plugins installed: Plug-in No.2- Java Deployment Toolkit [Location: npdeployJava1.dll], Plug-in No.3- Java(TM) Platform SE 7 U1 [Location: npjp2.dll], Plug-in No.4- Microsoft Office 2003 [Location: NPOFFICE.DLL]... I also need to save this information in a file on the server. All users are having firefox or chrome. How do I do this considering javascript can't write files on the server. I also don't want to use activex. Is there a way to redirect the javascript output to php?

<script language="JavaScript1.2">
document.write("Your current resolution is "+screen.width+"*"+screen.height+"")
var num_of_plugins = navigator.plugins.length;
for (var i=0; i < num_of_plugins; i++) {
var list_number=i+1;
document.write("<font color=red>Plug-in No." + list_number + "- </font>"+navigator.plugins[i].name+" <br>[Location: " + navigator.plugins[i].filename + "]<p>");


Old Pedant
06-28-2012, 01:37 AM
Of course you could send the info to PHP and then PHP could save it in a database.

But your JavaScript code is dated. You should avoid using language="..." in the <script> tag and you should definitely avoid using document.write

As to how to get that same content to the server: Most people would probably opt to use AJAX. Very well known technology, tons of tutorials on it.

Oh...and the <font> tag is deprecated, as well. Time to stop using it is long past.

06-28-2012, 02:15 AM
I don't want to be rude but I'm really clueless about the AJAX thing. Can you be a bit more specific?

Old Pedant
06-28-2012, 02:38 AM
Not rude at all. In fact, you do the right thing by saying you need more information.

You can start learning about it here:

Basically, it's a means of sending data to the server without the user really being aware it is happening.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum