Solved

retrive value from a text file & use it in html

Posted on 2000-05-08
6
150 Views
Last Modified: 2010-04-09
I want to put a text file on my webpage, say version.txt with one line in it 'Version 1.2'.  I want then all my other html pages to display this version number so I don't have to change each page, just the contents of the text file...or can I have a Global variable in my index.htm file which can be used by other pages? can't use ASP etc.
0
Comment
Question by:degziebob
  • 4
  • 2
6 Comments
 
LVL 8

Expert Comment

by:jbirk
ID: 2788102
If you can use SSI (server side includes) you can easily just pick a spot on each web page and put the appropriate include tag (for whatever version of SSI you have), and the server will then grab the text from that document and include it in the web page.  The user will see it as if it was actually part of the web page.  SSI is realy nice if you have it:)

If you don't, then the variable method is a possibility.  If you are using frames, then it's a little easier, if not you'd have to use cookies.  The only drawback to cookies is that it will take more code on every single page you want to have this version number (cookie code can be big!).  With frames a simple document.write(top.version) will do.

Tell me which method you'd like to pursue and I can work on a solution for you.

-Josh
0
 

Author Comment

by:degziebob
ID: 2788669
I'm happy enough to put a bit of code in each page that will display the version.  This code won't change, just the text file.

Thanks....don't think I have SSI, & dont want to use frames.
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2789463
So you're saying you want to go with the cookie method?  For this method you don't actually have a seperate text file.  You just update the version info in the main page or pages, and then once they are loaded again, they will set the cookie with the proper value and any other pages on your site after that will get that cookie and display the info.  The only problem you will have is if someone has cookies or javascript turned off, and if they don't go to your main page (I.E. bookmarking a page deep into the site and never returning to the home page, like I do here with EE).  In my opinion this is the worst and most difficult one to do, but with no SSI, I guess there's not many options...

Still interested?  The cookie code can be kind of long.  You'll probably want to include it via a javascript include to reduce load time (it gets cached).

-Josh
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:jbirk
ID: 2789482
D'oh!  That reminds me of a much better solution!

Use javascript include to include the variable.  Then use a document.write to write it out.  Code coming...

-Josh
0
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 2789495
OK, the file should be called version.js or something like that and look like this (just one line:
var version = "Version 1.2"


Then to include it:
<SCRIPT language="JavaScript" src="/version.js"></SCRIPT>


Then wherever you want this to go in the document:
<SCRIPT language="JavaScript">
<!--
document.write(version);
// -->
</SCRIPT>


That's it!  Pretty easy hunh?

-Josh
0
 

Author Comment

by:degziebob
ID: 2804396
perfect!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Blog posts not showing up on Blog page 7 51
Apply tab index in forms 6 33
Centered Image 2 21
compact pure CSS Read More Toggle 4 19
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now