#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    2
    Rep Power
    0

    Question including other html pages using javascript


    Hello all...

    I am trying to include into a html page other html pages ie as footers or headers or navigation etc. using javascript ...

    I think I have seen this done before but cannot remember it. I usually use Cold Fusion ... but this site is not running a CF server.

    Does anyone have a script for this or more importantly ... can it be done?

    BTW: It has to be client side & not perl etc etc

    Thanks in advance for any help
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    You can't do a client-side (HTML) 'include' - so you'll need to use an external .js file to write the HTML output to the page.

    1) Convert the HTML to a JavaScript string. You can use one of a number of tools around the web (example).

    2)Put it in a file, pure JavaScript, name the file - get the word 'include' in there (or in the directory) if possible. At the end of the string, type in: document.write(string_name);

    3)Embed this:

    <script type="text/javascript" language="javascript" src="directory/filename.js">
    </script>

    ..at the spot on the page where you'd like the HTML to be echoed. You can do this on several pages, with the cached script being instantly read in for each. Dynamic effects (time/date/whatever) involving run-time calculations are, of course, possible.

    Not a substitute for server processes, but it works....
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    2
    Rep Power
    0
    Thanks... the problem is the files we need to include are on other servers ... I'll have a play with your suggestion though

    Thanks for the quick response = )
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    sydeny nsw aus
    Posts
    53
    Rep Power
    15
    Hi there, I encounter the same problem, have you got answer, tell me how to do it, please! thanks indeed
  8. #5
  9. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Do what? Include files from other servers? Or write the same block of HTML to multiple pages using JavaScript?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    sydeny nsw aus
    Posts
    53
    Rep Power
    15
    yes, Include files from other servers
  12. #7
  13. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    Probably use an <iframe>.
    Last edited by adios; May 18th, 2003 at 02:51 AM.

IMN logo majestic logo threadwatch logo seochat tools logo