?
Solved

include content from one html file in another

Posted on 2003-02-23
20
Medium Priority
?
260 Views
Last Modified: 2013-11-18
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
Comment
Question by:muskad202
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 4
  • 2
  • +5
20 Comments
 
LVL 5

Expert Comment

by:gator4life
ID: 8004359
There are many ways to do this.  What is the exact thing that you want to do?

gator4life
(chomp, chomp)
0
 
LVL 2

Author Comment

by:muskad202
ID: 8004401
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
 
LVL 17

Expert Comment

by:dorward
ID: 8004477
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Expert Comment

by:nyxoh
ID: 8004495
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
 
LVL 17

Expert Comment

by:dorward
ID: 8004532
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
 
LVL 2

Expert Comment

by:ActiveMedia
ID: 8004542
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8004822
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8004832
My preference is an iframe, in spite of not being a big fan of frames of any kind.

Cd&
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8006435
use some serverside programming language..
PHP or ASP?
0
 
LVL 2

Author Comment

by:muskad202
ID: 8006812
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
 
LVL 2

Author Comment

by:muskad202
ID: 8006828
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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 80 total points
ID: 8009876
<%
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
 
LVL 2

Author Comment

by:muskad202
ID: 8010041
nope COBOLdinosaur...that doesn't work....(see my comment just before yours).
muskad202
0
 
LVL 2

Author Comment

by:muskad202
ID: 8010055
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
 
LVL 2

Author Comment

by:muskad202
ID: 8010123
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
 
LVL 2

Author Comment

by:muskad202
ID: 8010146
hi nyxoh .. my provider does support server side includes...can u show me what should i do ??
thanks. :)
0
 
LVL 2

Author Comment

by:muskad202
ID: 8010172
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
 

Expert Comment

by:MrDickNetNick
ID: 8023506
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8820399
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
 
LVL 2

Author Comment

by:muskad202
ID: 8821888
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question