Solved

Placing text from a .txt file within HTML

Posted on 2012-04-11
5
184 Views
Last Modified: 2012-05-09
I'm looking for an easy way to get access a text file on a local machine, which contains the users name; I want to display on a HTML page. Is there way to do this preferably with Javascript.

So file is at %userprofile%\name.txt

I want to appear at <h2>Welcome to our site {DISPLAY NAME}</h2>

Any ideas?
0
Comment
Question by:piemckay
5 Comments
 
LVL 2

Expert Comment

by:kamalranjan
ID: 37832637
I believe you can not access local file system directly. Alternatively you can create a ActiveX control in VB or any other language and use that to access and fetch the desired data from the text file. You can then use that returned value from a function in that User Control and use that in your HTML page. Use Javascript to call the function from that ActiveX control and use the returned value in your respective HTML tag.
0
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37832638
<script language="javascript" src="text.txt"></script>

Then create a new text file in the same folder as your html file called text.txt and put this in it:

document.write('Your text file');


http://www.webmasterworld.com/forum21/11352.htm
0
 

Author Comment

by:piemckay
ID: 37832740
Yes it would appear to be impossible to use a serverside script to access data on the client. I will have a look at using activex. Any suggestions?
0
 
LVL 23

Accepted Solution

by:
basicinstinct earned 500 total points
ID: 37836566
it is impossible to access a file on the client machine file system under normal conditions...

why don't you use cookies instead?

if you ONLY need to support IE and you can set the browser to put your site trusted or intranet zone then you can script the FileSystemObject
0
 

Author Closing Comment

by:piemckay
ID: 37946328
Most helpful suggestion.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question