How can I "include" an HTML file from *another* server?

Discussion in 'Javascript' started by indessen@hotmail.de, Mar 18, 2006.

  1. Guest

    Hi,

    got the following problem: I need to include an HTML file that sits on
    another server B in an HTML file that sits on server A, and I need to
    include this at a particular place in the file. The "include" command
    doesnt work obviously as it is server-side.

    In other words: say I have a webpage, at a particular place, for
    example halfway down, I want to include HTML that sits on another
    server.

    Can anyone point to a javascript code that can do this?

    Thanks!

    Michael
    , Mar 18, 2006
    #1
    1. Advertising

  2. Evertjan. Guest

    wrote on 18 mrt 2006 in comp.lang.javascript:
    > got the following problem: I need to include an HTML file that sits on
    > another server B in an HTML file that sits on server A, and I need to
    > include this at a particular place in the file. The "include" command
    > doesnt work obviously as it is server-side.


    That would only be obvious if you preclude that serverside coding.

    > In other words: say I have a webpage, at a particular place, for
    > example halfway down, I want to include HTML that sits on another
    > server.
    >
    > Can anyone point to a javascript code that can do this?


    Use in IE:

    function getUrl(url) {
    var http = new ActiveXObject("microsoft.xmlhttp");
    http.open("GET",url,false);
    http.send();
    return http.responseText;
    }

    Look here:

    <http://xkr.us/code/javascript/XHConn/>

    for a more cross browser solution.

    Many security settings will give you a nightmare, so:

    The best solution is swapping your server to an ASP (or PHP) one!

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 18, 2006
    #2
    1. Advertising

  3. wrote:

    > In other words: say I have a webpage, at a particular place, for
    > example halfway down, I want to include HTML that sits on another
    > server.


    There is the HTML iframe element and the object element, both allow you
    to insert a document from a different server e.g.
    <iframe src="http://example.org/whatever.html"></iframe>
    or e.g.
    <object type="text/html"
    data="http://example.org/whatever.html"></object>

    Client-side script does not help at all.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 18, 2006
    #3
  4. Guest

    thanks all, iframe seems to do the job!
    , Mar 21, 2006
    #4
    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. Replies:
    3
    Views:
    12,157
    Beauregard T. Shagnasty
    Jan 10, 2006
  2. Tom
    Replies:
    8
    Views:
    665
    Adrienne Boswell
    Feb 13, 2007
  3. Andreas Bogenberger
    Replies:
    3
    Views:
    902
    Andreas Bogenberger
    Feb 22, 2008
  4. Poirot
    Replies:
    0
    Views:
    1,428
    Poirot
    May 11, 2011
  5. ym
    Replies:
    0
    Views:
    148
Loading...

Share This Page