Solved

Placing text from a .txt file within HTML

Posted on 2012-04-11
5
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

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.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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…

726 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