Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to include page content

Status
Not open for further replies.

spicymango

Programmer
May 25, 2008
119
CA
Hi,

I have a html page on a domain abc.com. In it I have a table.

Page A
Code:
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width 550 height=400>

//include the page B from domain xyz.com

</table>
</body>
</html>

I have another page on a different domain xyz.com

that page has code

Page B
Code:
<tr></td>1 </tr></td>
<tr></td>2 </tr></td>
<tr></td>3 </tr></td>
<tr></td>4 </tr></td>

I want to include the code of page B in my Page A table? How can I do that (With out Iframe)

Thanks
 
With either server side includes (SSI) or some type of server side language. (PHP or ASP)

forum333
forum434





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
If you want to do it without frames, and without using server-side coding (assuming you don't know any), then you could restructure your data on xyz.com to be contained in a JS file and simply include that file and parse the data that way.

This, of course, assumes that you have access to the re-work the data on xyz.com and you're not simply ripping off someone else's data.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Thanks for your replies
I know on the server side you can do
<!--#include virtual="/mymenu_text.shtml" -->

But in my case the file that I need to include is not on the same server, its on a different server , so I guess I am out of luck here.

 
PHP or ASP can include files in other domains provided the other domain allows it.

But of course the coding will be different depending on what language you have at hand.

In PHP you can use a simple Include or even CURL to include the file from another domain such as:

include('
This will bring in the file in the specified location. provided the server this is run on has the allow_url_fopen enabled.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
No but in my case I can not use PHP or ASP, I need to do it only in html
 
Sorry, there's no way to dynamically include content in HTML alone. HTML is a static language.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
No but in my case I can not use PHP or ASP, I need to do it only in html

Then, if iframes are still a "no-no", my suggestion of including a JS file is a good way to go.

Like I said, though, you'd need access to restructure the data on xyz.com so if you're ripping off someone else's data, this obviously won't work. Having said that, if you're ripping off someone else's data, perhaps it's a good thing you can't include it!

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

Dan said:
Like I said, though, you'd need access to restructure the data on xyz.com
Or a solution for the future : just get it with AJAX.

But of course, xyz.com's administrator can reject your request. See Cross-Origin Resource Sharing ( W3C Working Draft ), HTTP Access Control ( its implementation in Gecko ) and [tt]XDomainRequest[/tt] Object ( Trident is on its own way, again ). It is also implemented in WebKit.

Feherke.
 
someone told me use http get its very easy to pull the content.

I don't know what he ia talking about, I google http get I can not make any sense out of it. It probably don't apply in my situation.


 
This works in IE, but not FF for some reason. Here is some AJAX code you can use to get the remote information.

This code uses AJAX to go out and read the HTML source code of the page. Hope this helps and makes sense!

Code:
<HTML>
<HEAD>
<SCRIPT>
var xmlHttp;

function getXHR(){
    try {
        // Firefox, Opera 8.0+, Safari
          xmlHttp = new XMLHttpRequest();
		  xmlHttp.overrideMimeType('text/html');
    }catch (e) {
          // Internet Explorer
          try{
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e) {
            try {
                  xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
              }catch (e) {
                  alert("Your browser does not support AJAX!");
                  return false;
              }
        }
      }
	  
	  
}

function getHTML() {
	getXHR();

	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4) {
			
			var htmlTable = "<table border=0 cellpadding=0 cellspacing=0 width 550 height=400>";
			htmlTable += xmlHttp.responseText;
			htmlTable += "</table>";
			
			document.getElementById("htmlTableDiv").innerHTML = htmlTable;
		}
	};

	xmlHttp.open("GET", "[URL unfurl="true"]http://www.google.com",[/URL] true);

	xmlHttp.send(null);
}


</SCRIPT>
</HEAD>

<BODY>

<INPUT TYPE="button" VALUE="get page" onClick="getHTML()" />

<div id="htmlTableDiv">
</div>

</BODY>
</HTML>
 
Hi

MikeyJudd said:
This works in IE, but not FF for some reason.
If you have FireFox 3.5 or newer, then see my comment at 4 Feb 10 4:33. Supposing you not own google.com, that is probably a cross-domain request, so [tt]XMLHttpRequest[/tt] will not allow the script to handle the received response, unless the response contains an [tt]Access-Control-Allow-Origin[/tt] header which allows it.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top