By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

Read a file from disk

P: n/a
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,heig ht=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

Nov 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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,heig ht=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/
Nov 21 '06 #2

P: n/a
In comp.lang.javascript message
<11**********************@h48g2000cwc.googlegroups .com>, Mon, 20 Nov
2006 06:08:36, morellik <en************@gmail.comwrote:
>
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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 21 '06 #3

P: n/a

Thanks to all,

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

Enrico

Nov 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.