Read a file from disk

M

morellik

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
 
R

Randy Webb

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.
 
D

Dr J R Stockton

In comp.lang.javascript message
Mon said:
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.
 
M

morellik

Thanks to all,

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

Enrico
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top