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

I

indessen

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
 
E

Evertjan.

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!
 
M

Martin Honnen

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top