Advanced Search

Results 1 to 4 of 4

Thread: writing the same info/text to HTML from one source

  1. #1
    Join Date
    Aug 2005
    Location
    Dorset, England
    Posts
    46
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default writing the same info/text to HTML from one source

    I've spent several hours (over days) trying to find a solution to this probably very simple piece of code.

    I want to display a version number in at least two places on all the pages of the site running to about 20 so far... Currently using Notepad++ 'find and replace' to change this version number but have on occasion missed a page or two.

    The site sits on a business Intranet and also is likely to be distributed on disk for standalone/local LANs, so no access to server side stuff technology that I know of. Below is an sample layout of what I mean. The version number may even crop up in the content text when being referred to.

    Click image for larger version. 

Name:	versions.jpg 
Views:	156 
Size:	8.6 KB 
ID:	4971

    I have tried all sorts of code abominations cut and pasted from the web, this one below being one I tried from scratch to no avail:

    In my HTML <head>
    Code:
    <script type="text/javascript" src="version.js"></script>
    Content of the referenced .js file
    Code:
    var myText = "1.7.0";
    within my <body> where I want the version number to appear
    Code:
    <script type="text/javascript">document.write(myText);</script>
    I had a go, got completely lost in all this, I really hope some one can help.

    with anticipated thanks,

    Dom
    Last edited by FordCorsair; 03-08-2013 at 09:26 AM. Reason: spelling

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,621
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    This would be simpler using a server-side language (like PHP). Your text editor is probably your next-best-bet, however. I believe notepad++ has a "find in files" search & replace function...?
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  3. #3
    Join Date
    Aug 2005
    Location
    Dorset, England
    Posts
    46
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Adrian,

    thanks for your response, I would have preferred to have gone the PHP route (includes) but the html files are sent to someone else and then hosted on MS Windows based servers (ASP??) and accessed via share point on our business intranet. Also the website pages are to be distributed via CD/DVD for stand alone PCs.

    I currently use the 'find/replace' tool in Notepad++ with all the docs open at once, but I was just wondering if this could be done using javascript and then I only have one file (the .js) to amend.

    thanks,

    Dom

  4. #4
    Join Date
    Aug 2005
    Location
    Dorset, England
    Posts
    46
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    ::SOLVED::

    my error was that my linked file in my <head>:
    Code:
    <script type="text/javascript" src="version.js"></script>
    wasn't linked properly, it should have been
    Code:
    <script type="text/javascript" src="scripts/version.js"></script>
    as I'd put it in a "scripts" folder/directory. All the other code is unchanged. If there is a better practise (semantically) I'd be interested to see it.

    Thanks for watching.

    Dom

Similar Threads

  1. Replies: 1
    Last Post: 01-03-2009, 11:19 PM
  2. How to submit html form info to sessions
    By Doomtomb in forum PHP
    Replies: 7
    Last Post: 12-20-2008, 08:13 PM
  3. Retrieving info from a text file using php.
    By hmsnacker123 in forum Looking for such a script or service
    Replies: 4
    Last Post: 06-01-2008, 02:33 AM
  4. html source protector
    By annevan in forum JavaScript
    Replies: 1
    Last Post: 06-11-2007, 08:29 PM
  5. Replies: 1
    Last Post: 03-08-2005, 05:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •