Read a file from disk

Discussion in 'Javascript' started by morellik, Nov 20, 2006.

  1. morellik

    morellik Guest

    Dear all,

    I'm a newbie of JS. I'm starting to write a web application that has
    some fields where I want to put
    an help icon. When the user click on the icon, appears a new little
    browser with the help inside.

    I have the following code:

    var header = "<html><head><link REL='stylesheet' TYPE='text/css'
    href='/css/help.css'></head><body><fieldset><legend>Help</legend>";
    var footer = '</fieldset><center><input type=button class="button"
    value="Click to close when finished"
    onClick=window.close()></center></body></html>';

    var cyana_protein_name = "Enter the protein name without spaces
    inside";

    function helpme(name) {
    if (name=='cyana_protein_name') {
    msg=cyana_protein_name;
    }

    newwin =
    window.open('','','top=150,left=150,width=325,height=200');
    if (!newwin.opener) newwin.opener = self;
    with (newwin.document)
    {
    open();
    write(header);
    write(msg + '<br>');
    write(footer);
    close();
    }
    }

    So, for some help works well, but I'll have a lot of help to display.
    Is it possible to read from the server disk a text file based on the
    name passed to the helpme function
    and display the file content?

    Thanks Enrico
     
    morellik, Nov 20, 2006
    #1
    1. Advertising

  2. morellik

    Randy Webb Guest

    morellik said the following on 11/20/2006 9:08 AM:
    > Dear all,
    >
    > I'm a newbie of JS. I'm starting to write a web application that has
    > some fields where I want to put
    > an help icon. When the user click on the icon, appears a new little
    > browser with the help inside.
    >
    > I have the following code:
    >
    > var header = "<html><head><link REL='stylesheet' TYPE='text/css'
    > href='/css/help.css'></head><body><fieldset><legend>Help</legend>";
    > var footer = '</fieldset><center><input type=button class="button"
    > value="Click to close when finished"
    > onClick=window.close()></center></body></html>';
    >
    > var cyana_protein_name = "Enter the protein name without spaces
    > inside";
    >
    > function helpme(name) {
    > if (name=='cyana_protein_name') {
    > msg=cyana_protein_name;
    > }
    >
    > newwin =
    > window.open('','','top=150,left=150,width=325,height=200');
    > if (!newwin.opener) newwin.opener = self;
    > with (newwin.document)
    > {
    > open();
    > write(header);
    > write(msg + '<br>');
    > write(footer);
    > close();
    > }
    > }
    >
    > So, for some help works well, but I'll have a lot of help to display.
    > Is it possible to read from the server disk a text file based on the
    > name passed to the helpme function
    > and display the file content?


    Make your help files .js files and then you can read them - easily -
    from the server. It also makes it easier to handle the text as JS data
    than if it is plain text.

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Nov 21, 2006
    #2
    1. Advertising

  3. In comp.lang.javascript message
    <>, Mon, 20 Nov
    2006 06:08:36, morellik <> wrote:
    >
    >So, for some help works well, but I'll have a lot of help to display.
    >Is it possible to read from the server disk a text file based on the
    >name passed to the helpme function
    >and display the file content?


    For me, testing locally in js-quick.htm, the code

    XX = window.open("js-alarm.htm", "fred")
    XX.document.getElementById("Until").innerHTML = "Friday"

    opens js-alarm.htm and sets element Until to read Friday.

    That should get you started; you can for example load a fairly general
    help file instead of js-alarm.htm and customise it with something
    instead of Friday.

    It's a good idea to read the newsgroup and its old FAQ. See below.

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
    <URL:http://www.jibbering.com/faq/> Old RC FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr J R Stockton, Nov 21, 2006
    #3
  4. morellik

    morellik Guest

    Thanks to all,

    I'll read the documentation and start to test yours suggestions.

    Enrico
     
    morellik, Nov 22, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jas Shultz
    Replies:
    0
    Views:
    1,000
    Jas Shultz
    Dec 3, 2003
  2. !George Sgouros
    Replies:
    8
    Views:
    493
    Tor Iver Wilhelmsen
    Dec 23, 2003
  3. Replies:
    2
    Views:
    409
  4. Replies:
    12
    Views:
    543
    santosh
    Nov 15, 2006
  5. Alex Dowad
    Replies:
    4
    Views:
    323
    Michel Demazure
    May 1, 2010
Loading...

Share This Page