Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write javascript output to file on server

    Hi.
    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 7.0.10.8 [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?

    Code:
    <html>
    <body>
    <script language="JavaScript1.2">
    document.write("Your current resolution is "+screen.width+"*"+screen.height+"")
    </script>
    <BR><BR>
    <SCRIPT LANGUAGE="JavaScript">
    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>");
    }
    </script>
    </body>
    </html>
    Thanks

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't want to be rude but I'm really clueless about the AJAX thing. Can you be a bit more specific?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Not rude at all. In fact, you do the right thing by saying you need more information.

    You can start learning about it here:
    http://www.w3schools.com/ajax/default.asp

    Basically, it's a means of sending data to the server without the user really being aware it is happening.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •