Including HTML files within another HTML file

Discussion in 'Javascript' started by Ralf Koms, Oct 11, 2004.

  1. Ralf Koms

    Ralf Koms Guest

    Hi,

    I would like to reference some other HTML files within an "main" HTML file
    (within the "header"),
    Something like this:

    <link rel="part1" href="file1.htm">
    <link rel="part2" href="file2.htm">
    <link rel="part3" href="file3.htm">

    etc.

    I would then like to include (within the BODY section) the HTML code of the
    referenced pages within the "main" HTML file.

    E.g. in a table:

    <table>
    <tr>
    <td>
    Code of file1.htm
    </td>
    </tr>
    <tr>
    <td>
    Code of file2.htm

    etc.

    My idea was to fetch via

    document.getElementsByTagName("link") or
    document.getElementsByID(...)

    the appropriate objects and to iterate over them.
    But how can I then write out the actual code contained in the HTML parts I
    want to include ?
    Is there sth. like "write.out()" ?

    Or is there an even easier way ?

    Thanks...
     
    Ralf Koms, Oct 11, 2004
    #1
    1. Advertising

  2. Ralf Koms

    Randy Webb Guest

    Ralf Koms wrote:

    > Hi,
    >
    > I would like to reference some other HTML files within an "main" HTML file
    > (within the "header"),
    > Something like this:
    >
    > <link rel="part1" href="file1.htm">
    > <link rel="part2" href="file2.htm">
    > <link rel="part3" href="file3.htm">


    Easily done using Server Side Includes, or any other Server Side
    Mechanism to include files.

    > etc.
    >
    > I would then like to include (within the BODY section) the HTML code of the
    > referenced pages within the "main" HTML file.
    >
    > E.g. in a table:
    >
    > <table>
    > <tr>
    > <td>
    > Code of file1.htm
    > </td>
    > </tr>
    > <tr>
    > <td>
    > Code of file2.htm
    >
    > etc.
    >
    > My idea was to fetch via
    >
    > document.getElementsByTagName("link") or
    > document.getElementsByID(...)
    >
    > the appropriate objects and to iterate over them.
    > But how can I then write out the actual code contained in the HTML parts I
    > want to include ?


    Not very easily.

    > Is there sth. like "write.out()" ?


    No.

    > Or is there an even easier way ?


    Yes. Do it on the server.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Oct 11, 2004
    #2
    1. Advertising

  3. Ralf Koms

    Ralf Koms Guest

    "Randy Webb" <> wrote in message
    news:...
    > Ralf Koms wrote:
    >
    > > Hi,
    > >
    > > I would like to reference some other HTML files within an "main" HTML

    file
    > > (within the "header"),
    > > Something like this:
    > >
    > > <link rel="part1" href="file1.htm">
    > > <link rel="part2" href="file2.htm">
    > > <link rel="part3" href="file3.htm">

    >
    > Easily done using Server Side Includes, or any other Server Side
    > Mechanism to include files.
    >
    > > etc.
    > >
    > > I would then like to include (within the BODY section) the HTML code of

    the
    > > referenced pages within the "main" HTML file.
    > >
    > > E.g. in a table:
    > >
    > > <table>
    > > <tr>
    > > <td>
    > > Code of file1.htm
    > > </td>
    > > </tr>
    > > <tr>
    > > <td>
    > > Code of file2.htm
    > >
    > > etc.
    > >
    > > My idea was to fetch via
    > >
    > > document.getElementsByTagName("link") or
    > > document.getElementsByID(...)
    > >
    > > the appropriate objects and to iterate over them.
    > > But how can I then write out the actual code contained in the HTML parts

    I
    > > want to include ?

    >
    > Not very easily.
    >
    > > Is there sth. like "write.out()" ?

    >
    > No.
    >
    > > Or is there an even easier way ?

    >
    > Yes. Do it on the server.
    >
    > --


    The thing is I need a solution not doing this with a server-side script
    language.
    I also do not want to use IFrames/Frames.
    So what are the possible ways ?
     
    Ralf Koms, Oct 11, 2004
    #3
  4. Ralf Koms

    Randy Webb Guest

    Ralf Koms wrote:

    > "Randy Webb" <> wrote in message
    > news:...
    >
    >>Ralf Koms wrote:
    >>
    >>
    >>>Hi,
    >>>
    >>>I would like to reference some other HTML files within an "main" HTML

    >
    > file
    >
    >>>(within the "header"),
    >>>Something like this:
    >>>
    >>><link rel="part1" href="file1.htm">
    >>><link rel="part2" href="file2.htm">
    >>><link rel="part3" href="file3.htm">

    >>
    >>Easily done using Server Side Includes, or any other Server Side
    >>Mechanism to include files.
    >>
    >>
    >>>etc.
    >>>
    >>>I would then like to include (within the BODY section) the HTML code of

    >
    > the
    >
    >>>referenced pages within the "main" HTML file.
    >>>
    >>>E.g. in a table:
    >>>
    >>><table>
    >>><tr>
    >>><td>
    >>> Code of file1.htm
    >>></td>
    >>></tr>
    >>><tr>
    >>><td>
    >>> Code of file2.htm
    >>>
    >>>etc.
    >>>
    >>>My idea was to fetch via
    >>>
    >>>document.getElementsByTagName("link") or
    >>>document.getElementsByID(...)
    >>>
    >>>the appropriate objects and to iterate over them.
    >>>But how can I then write out the actual code contained in the HTML parts I
    >>>want to include ?


    <--snip-->

    > The thing is I need a solution not doing this with a server-side script
    > language.
    > I also do not want to use IFrames/Frames.
    > So what are the possible ways ?


    Use an HTTP Request object, then create nodes, and insert the text/html
    into those nodes. Then ask why it only works in IE and Mozilla. Consult
    the FAQ on how to accomplish the HTTPRequest Object. And then, depending
    on what is in the HTML files, you may just have to eval it <shudder> if
    it contains JS code.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Oct 12, 2004
    #4
  5. Ralf Koms

    Ralf Koms Guest

    "Randy Webb" <> wrote in message
    news:...
    > Ralf Koms wrote:
    >
    > > "Randy Webb" <> wrote in message
    > > news:...
    > >
    > >>Ralf Koms wrote:
    > >>
    > >>
    > >>>Hi,
    > >>>
    > >>>I would like to reference some other HTML files within an "main" HTML

    > >
    > > file
    > >
    > >>>(within the "header"),
    > >>>Something like this:
    > >>>
    > >>><link rel="part1" href="file1.htm">
    > >>><link rel="part2" href="file2.htm">
    > >>><link rel="part3" href="file3.htm">
    > >>
    > >>Easily done using Server Side Includes, or any other Server Side
    > >>Mechanism to include files.
    > >>
    > >>
    > >>>etc.
    > >>>
    > >>>I would then like to include (within the BODY section) the HTML code of

    > >
    > > the
    > >
    > >>>referenced pages within the "main" HTML file.
    > >>>
    > >>>E.g. in a table:
    > >>>
    > >>><table>
    > >>><tr>
    > >>><td>
    > >>> Code of file1.htm
    > >>></td>
    > >>></tr>
    > >>><tr>
    > >>><td>
    > >>> Code of file2.htm
    > >>>
    > >>>etc.
    > >>>
    > >>>My idea was to fetch via
    > >>>
    > >>>document.getElementsByTagName("link") or
    > >>>document.getElementsByID(...)
    > >>>
    > >>>the appropriate objects and to iterate over them.
    > >>>But how can I then write out the actual code contained in the HTML

    parts I
    > >>>want to include ?

    >
    > <--snip-->
    >
    > > The thing is I need a solution not doing this with a server-side script
    > > language.
    > > I also do not want to use IFrames/Frames.
    > > So what are the possible ways ?

    >
    > Use an HTTP Request object, then create nodes, and insert the text/html
    > into those nodes. Then ask why it only works in IE and Mozilla. Consult
    > the FAQ on how to accomplish the HTTPRequest Object. And then, depending
    > on what is in the HTML files, you may just have to eval it <shudder> if
    > it contains JS code.
    >


    What do you mean by "nodes" ?
     
    Ralf Koms, Oct 12, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vish
    Replies:
    2
    Views:
    1,778
    Steve C. Orr, MCSD
    Jul 16, 2003
  2. Tony Prichard
    Replies:
    0
    Views:
    789
    Tony Prichard
    Dec 12, 2003
  3. mrhicks
    Replies:
    2
    Views:
    460
    Dave Thompson
    Jun 10, 2004
  4. Replies:
    6
    Views:
    355
    Thomas Hawtin
    Aug 11, 2007
  5. vunet
    Replies:
    2
    Views:
    170
    Laser Lips
    Jul 8, 2008
Loading...

Share This Page