degziebob
asked on
retrive value from a text file & use it in html
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.
ASKER
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.
Thanks....don't think I have SSI, & dont want to use frames.
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
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
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
Use javascript include to include the variable. Then use a document.write to write it out. Code coming...
-Josh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect!
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
Tell me which method you'd like to pursue and I can work on a solution for you.
-Josh