Solved

Placing text from a .txt file within HTML

Posted on 2012-04-11
5
185 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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