1

i am making some script for some personal use. Now i tend to keep my CD collection list in a html file which has some sleek design, but i am tired of editing the list by "hand" and that means that i don't want to edit the code everytime i add new CD. So is there a way that i can use JS or JQuery so i could add/read from a local file(this script is not remote it is local(although i might try to host it remote).

I don't want to use any other language than HTML, CSS and JS/JQuery.

EDIT: Is it possible to add a link that when i click some application on my computer would launch.

dimitar
  • 153
  • 2
  • 7
  • If what you're asking for is access to the file system with clientside (in browser) javascript, you're most likely out of luck: http://stackoverflow.com/questions/1087246/can-javascript-access-a-filesystem – Jamie Wong Aug 16 '10 at 17:51

2 Answers2

1

Not if you only want to use HTML and javascript. You will need a server side script of some kind to write to a file.

The comments got me thinking, I know this is not really what you were asking but you could play around with server side javascript with node.js

HurnsMobile
  • 4,341
  • 3
  • 27
  • 39
  • While not yet fully supported, this should be possible using HTML5's local storage. – Jamie Wong Aug 16 '10 at 17:49
  • but the script will be on my computer so my pc will be server and client in same time. I think it should be possible somehow.. :D – dimitar Aug 16 '10 at 19:48
  • Why? JavaScript is sandboxed so it can't touch the local machine (except through certain very limited channels). A web server running locally is just another web server accessed over the network (even if it is the loopback interface) as far as JS is concerned. – Quentin Aug 16 '10 at 20:21
  • Even though the script is on your computer, its executed by an engine running in browser. – Tushar Tarkas Aug 16 '10 at 20:21
0

You can do it like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>CD Collection</title>
    <script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8">
        var cds = ['cd1', 'cd2', 'cd3'];
        $(function() {
            $(cds).each(function() {
                $('#cd_list').append('<li>' + this + '</li>')
            });
        });
    </script>
</head>
<body>
    <p>
        <ul id="cd_list"></ul>
    </p>
</body>
</html>

The inline js with the cd list can be loaded in as a separate file in the same way jquery was pulled in.

Matt Williamson
  • 39,165
  • 10
  • 64
  • 72