Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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
0
muskad202
Asked:
muskad202
  • 9
  • 4
  • 2
  • +5
1 Solution
 
gator4lifeCommented:
There are many ways to do this.  What is the exact thing that you want to do?

gator4life
(chomp, chomp)
0
 
muskad202Author Commented:
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
0
 
dorwardCommented:
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)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
nyxohCommented:
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?
0
 
dorwardCommented:
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.
0
 
ActiveMediaCommented:
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
0
 
COBOLdinosaurCommented:
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>

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

Cd&
0
 
JonzaCommented:
use some serverside programming language..
PHP or ASP?
0
 
muskad202Author Commented:
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
0
 
muskad202Author Commented:
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
0
 
COBOLdinosaurCommented:
<%
Response.Buffer = True

Function include( url )
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", url, False
xml.Send
include = xml.responseText
Set xml = Nothing
End Function
%>

And because XML is being used I would ecpect that this is case sensitive.

Cd&
0
 
muskad202Author Commented:
nope COBOLdinosaur...that doesn't work....(see my comment just before yours).
muskad202
0
 
muskad202Author Commented:
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 ?!@#$!!?
0
 
muskad202Author Commented:
hi guys !!
i might have found a solution as to why the asp/xml thing wasn't working...

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20414175.html

anyone got any more ideas ??

muskad202
0
 
muskad202Author Commented:
hi nyxoh .. my provider does support server side includes...can u show me what should i do ??
thanks. :)
0
 
muskad202Author Commented:
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 ??
0
 
MrDickNetNickCommented:
Copy and Paste :)  

Just kidding.  If you are using the latest Frontpage(which I despise) there is already "Include Page" insert in the menu.
0
 
COBOLdinosaurCommented:
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:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
muskad202Author Commented:
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...

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20414175.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
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 9
  • 4
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now