Link to home
Start Free TrialLog in
Avatar of muskad202
muskad202

asked on

include content from one html file in another

hello.
can anyone tell me  how using only html or javascript, can i include the entire content of an html page (on some other site) into my html page?
thanks
muskad202
Avatar of gator4life
gator4life

There are many ways to do this.  What is the exact thing that you want to do?

gator4life
(chomp, chomp)
Avatar of muskad202

ASKER

hi
i have one html file, say index.html.
i have another html file, say abc.html
the files are located on different servers
i want to include the content of abc.html in index.html.
thanks
Iframe - nasty, unreliable, but about the only way:

http://www.allmyfaqs.com/faq.pl?Include_one_file_in_another

(Note that including third party content in this was could open you up to legal action if you don't have permission)
On easy way to do it is to use ssi (server side includes) do you have this enabled on your server? If you do you could also use perl.  I agree you could use an iframe but that is sloppy, although you could use javascript, is this page constantly being updated i'm presuming?
JavaScript?! I'd love (mainly becuase I don't believe it possible) to see some JavaScript capable of reading an HTML file from a remote server, then dumping the contents of the <body> element in the page the script is running on.
muskad202 - what exactly do you mean by "include"?

In programming languages/environments such as ASP, the term "INCLUDE" has a very specific meaning, that the code from one file (the INCLUDE file) is literally taken into another file and becomes part of that file just the same as if it was typed in with all the other code.

Perhaps what you want is something else.  Perhaps you want to be able to display HTML from both files in different areas of the window at the same time?

IF so, you can use a simple FRAMESET. The source of HTML for each frame can be on a different server STC.

HTH
dorward,

Not possible with conventional JavaScripting, but it can be done if you declare xmlhttp as an activeXobject.  Very ugly, and opens up serious guestions of legality if you don't have permission.  The following stolen from knightEknight:

<SCRIPT language='JavaScript'>

function include(url) // must be a fully qualified URL, I don't know why
{
if ( document.all )
{
var xml = new ActiveXObject("Microsoft.XMLHTTP");
xml.Open( "GET", url, false );
xml.Send()
document.writeln(xml.responseText);
}
else
{
if ((location.host == '' && url.indexOf(location.protocol) == -1) || url.indexOf(location.host) == -1)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalConnect");
}

var dest = new java.net.URL(url);
var dis = new java.io.DataInputStream(dest.openStream());
var res = "";
while ((line = dis.readLine()) != null)
{
res += line + java.lang.System.getProperty("line.separator");
}
dis.close();
document.writeln(res);
}
}

</script>

My preference is an iframe, in spite of not being a big fan of frames of any kind.

Cd&
use some serverside programming language..
PHP or ASP?
hi !!
firstly, there is no legal issue here...becoz both the pages are mine..
my server does support asp, and i had already tried it the xml way, but it kept on giving me an error on the line

xml.send

it just says "error '800c0005'"

i have checked with the provider, and they have said that xml 4.0 is supported...so, what's the problem ?? i just don't get it..so i was thinking it might be easier to do it in html or javascript, if possible..

thanks..
muskad202
note...i tried it with xmlhttp and asp .. like so :-

dim xml
set xml=server.createobject("microsoft.xmlhttp")
xml.Open "GET", url, false
xml.Send
response.write xml.responsetext
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
nope COBOLdinosaur...that doesn't work....(see my comment just before yours).
muskad202
anywayz cb..i tried it the way u showed me (with the function and everything..) it yet gives the same error..what does the error code mean ?!@#$!!?
hi guys !!
i might have found a solution as to why the asp/xml thing wasn't working...

https://www.experts-exchange.com/questions/20414175/Retrieve-XML-Data-Using-ASP.html

anyone got any more ideas ??

muskad202
hi nyxoh .. my provider does support server side includes...can u show me what should i do ??
thanks. :)
hi...
nyxoh, was just reading up some stuff on SSI, it says that the fies have t be on the same server, but my files are on 2 different servers..any soln ??
Copy and Paste :)  

Just kidding.  If you are using the latest Frontpage(which I despise) there is already "Include Page" insert in the menu.
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
https://www.experts-exchange.com/help/closing.jsp


Cd&

hi !!
even though i didn't get a proper working answer (to all those who mentioned using IFrames and Framesets....sorry..i already knew about that, but i don't think people would appreciate a site within a site...:)
CobolDinosaurs's comment about using XML came closest to what i was looking for....unfortunately, it didn't work --->
(a previous comment of mine)
------------------
hi guys !!
i might have found a solution as to why the asp/xml thing wasn't working...

https://www.experts-exchange.com/questions/20414175/Retrieve-XML-Data-Using-ASP.html

anyone got any more ideas ??

muskad202
--------------------------------------------------------------------
since i have to award the points to someone, i'll give them to Cd& :)
thanks to everyone for helping..
muskad202